Hacker News new | ask | show | jobs
ChatGPT: How many weekdays were there in June 2023? Answer: 4 days
13 points by Zolt 1055 days ago
Sorry if this does not belong here. I am usually quite pleased with the results I receive with ChatGPT; this is the worst I've received:

Question: how many weekdays were there in June 2023?

To determine how many weekdays were in June 2023, we need to count the number of weekdays for each day of the month and then sum them up.

June 2023 has 30 days, and we need to exclude weekends (Saturday and Sunday) from the count. Let's calculate:

1. June 2023 starts on a Friday (June 1st) and ends on a Saturday (June 30th). 2. There are five full weekends (10 weekend days) in June: June 3rd and 4th, June 10th and 11th, June 17th and 18th, June 24th and 25th, and June 30th. 3. The remaining weekdays are from Monday to Thursday, which amounts to 4 days.

So, the total number of weekdays in June 2023 is 4 days.

==

It also got the wrong answer for July 2023.

To determine how many weekdays were in July 2023, we need to count the number of weekdays for each day of the month and then sum them up.

July 2023 has 31 days, and we need to exclude weekends (Saturday and Sunday) from the count. Let's calculate:

1. July 2023 starts on a Saturday (July 1st) and ends on a Sunday (July 31st). 2. There are four full weekends (8 weekend days) in July: July 1st and 2nd, July 8th and 9th, July 15th and 16th, and July 22nd and 23rd. 3. The remaining weekdays are from Monday to Friday, which amounts to 23 days.

So, the total number of weekdays in July 2023 is 23 days.

It missed Saturday the 29th and Sunday the 30th.

5 comments

In every month, there are 5 weekdays: Monday, Tuesday, Wednesday, Thursday and Friday. ChatGPT is advocating for a 4-day workweek.
GPT 3.5 gives me 22 days in June and a fairly simple working out.

GPT 4 answers 20 days (wrong) and an overly complicated working out where it spends most of its time explaining Zeller's Congruence to find day of the week for the start day of June. By the time I read it I could probably have gone and found a paper calendar and counted.

ChatGPT-4 gets it right, saying this:

We can calculate the number of weekdays in June 2023 by examining each day of the month and counting the number of days that are not weekends (i.e., Saturday or Sunday).

Let's calculate the number of weekdays in June 2023: (Python code is produced.)

   from datetime import datetime, timedelta

   # Start date and end date for June 2023
   start_date = datetime(2023, 6, 1)
   end_date = datetime(2023, 6, 30)

   # Count the number of weekdays (Monday to Friday)
   weekday_count = 0
   current_date = start_date
   while current_date <= end_date:
       if current_date.weekday() < 5: # Monday to Friday are represented as 0 to 4
           weekday_count += 1
       current_date += timedelta(days=1)

   weekday_count

There are 22 weekdays in June 2023.
I would have changed the following two lines, that way, you don't have to know what the last day of the month is.

   end_date = datetime(2023, 7, 1)
   # ...
   while current_date < end_date:
This is a lot shorter though maybe harder to read:

  >>> import calendar
  >>> c = calendar.Calendar()
  >>> sum(d > 0 and calendar.MONDAY <= w <= calendar.FRIDAY for d, w in c.itermonthdays2(2023, 6))
  22
https://docs.python.org/3/library/calendar.html#calendar.Cal...
And again, people think they’ve fooled a generative model by forcing it to do calculations in English when allowing it to write code is way more reasonable and accurate. That this is “news” or interesting is laughable.
Well, it is arguable that it is "laughable" that there is a strong push to try and regulate/contain these systems to avoid human extinction when they can't tell you the number of weekdays in a month (and fail in this manner).

I'm no AI skeptic (and am aware the above does not seem to apply to GPT4), but the general point stands - finding these limitations is an interesting endeavor, and when they're particularly severe or unexpected, newsworthy.

If LLMs cause most 'well ackshually...' replies to be aimed at LLMs instead of humans, I think it's probably a small win for humanity. Let them have their smug satisfaction at outwitting some python code.
We get it, it's bad at math, the same way a truck is not great for watersports. Definitely worth being aware of but hopefully has stopped being a source of outrage.
It's already on the 4DWW (Four Day Work Week) schedule:

Mon, Tue, Wed, Thur = Four weekdays, and Friday is classified as the weekend ;)