Hacker News new | ask | show | jobs
by Bostonian 1055 days ago
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.
2 comments

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.