Live data from Hacker News

Lewis Carroll – computing the day of the week for any given date (1887)

futilitycloset.com

81–90 of 109 posts

Re: Lewis Carroll – computing the day of the week for any given date (1887)

#81

This is very similar to the method I use and, after conversation with him, the method Art Benjamin uses. It's trivial to do in 10 to 15 seconds, though it requires practice, a very small amount of memorisation[0], and a small amount of mental arithmetic. I use it regularly, partly to keep in practice, and partly because once you have the skill you find it's surprisingly useful. JH Conway used a different technique[1]…

This was the first explanation that I immediately memorised. Thank you for sharing. I got quite a few right, but as I experimented I failed on February 7th 2032. My math was:

    Years since 2012 is 20
    Leap years is 20/4 = 5
    Magic month number = 4
    Date is 7
    (20 + 5 + 4 + 7) % 7 = 1
So I was expecting Sunday, but the answer is Saturday. After some thought I realised: 2032 is a leap year and the chosen date is before February 29th. In those cases (on or before that day), it is necessary to subtract 1.

Re: Lewis Carroll – computing the day of the week for any given date (1887)

#83

This is very similar to the method I use and, after conversation with him, the method Art Benjamin uses. It's trivial to do in 10 to 15 seconds, though it requires practice, a very small amount of memorisation[0], and a small amount of mental arithmetic. I use it regularly, partly to keep in practice, and partly because once you have the skill you find it's surprisingly useful. JH Conway used a different technique[1]…

I learned this at MathCamp from Conway himself! The mnemonics he taught us for the “doomsdays” were:

> Even months aside from February, same date as the month, so 4/4, 6/6, 8/8, 10/10, 12/12.

> “Working 9 to 5 at 7-11”: 5/9, 7/11, 9/5, 11/7

> Jan–Mar are a bit arbitrary: Feb is the last day of the month (so 2/28 or 2/29), March is the 0th day (same), and Jan is 1/31 or 1/“32” depending on if it’s a leap year.

Re: Lewis Carroll – computing the day of the week for any given date (1887)

#84
post #56
post #28

Earlier quoted context omitted.

What do you mean, what knowing the day of week a date is useful for ?

Yes, that's what people typically use a calendar for. So you agree that this trick isn't useful for anything?

I'm reminded of the scene in Back To The Future II in which people in the 19th century scoffed that someday someone might "run for fun" despite the ubiquity of motorized transportation.

Re: Lewis Carroll – computing the day of the week for any given date (1887)

#86
# (jim) C:\Users\Jim>python dow.py

# Enter a date (yyyy-mm-dd): 2024-05-24

# The day of the week for 2024-05-24 is Friday.

def compute_day_of_week(date):

    day, month, year = date
    century = year // 100
    year_part = year % 100

    # Compute Century-Item
    if year 
def day_of_week_string(day_index):

    days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
    return days[day_index]
# Prompt for the date

date_input = input("Enter a date (yyyy-mm-dd): ")

year, month, day = map(int, date_input.split('-'))

date = (day, month, year)

# Compute and print the day of the week

day_index = compute_day_of_week(date) day_name = day_of_week_string(day_index) print(f"The day of the week for {date_input} is {day_name}.")

Re: Lewis Carroll – computing the day of the week for any given date (1887)

#87

# (jim) C:\Users\Jim>python dow.py # Enter a date (yyyy-mm-dd): 2024-05-24 # The day of the week for 2024-05-24 is Friday. def compute_day_of_week(date): day, month, year = date century = year // 100 year_part = year % 100 # Compute Century-Item if year def day_of_week_string(day_index): days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] return days[day_index] # Prompt for the date…

Including 1752 is problematic, in the British Empire, it was the only year with 355 days, as September 3–13 were skipped when the Empire adopted the Gregorian calendar.

These skipped days were a rolling problem across the world, when they were applied varied by country and religion of the recorder of historic accounts - they were by no means uniformly applied in the same year across the planet.

Re: Lewis Carroll – computing the day of the week for any given date (1887)

#88
post #87

# (jim) C:\Users\Jim>python dow.py # Enter a date (yyyy-mm-dd): 2024-05-24 # The day of the week for 2024-05-24 is Friday. def compute_day_of_week(date): day, month, year = date century = year // 100 year_part = year % 100 # Compute Century-Item if year def day_of_week_string(day_index): days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] return days[day_index] # Prompt for the date…

Including 1752 is problematic, in the British Empire, it was the only year with 355 days, as September 3–13 were skipped when the Empire adopted the Gregorian calendar. These skipped days were a rolling problem across the world, when they were applied varied by country and religion of the recorder of historic accounts - they were by no means uniformly applied in the same year across the planet.

[deleted]

Re: Lewis Carroll – computing the day of the week for any given date (1887)

#89
post #87

# (jim) C:\Users\Jim>python dow.py # Enter a date (yyyy-mm-dd): 2024-05-24 # The day of the week for 2024-05-24 is Friday. def compute_day_of_week(date): day, month, year = date century = year // 100 year_part = year % 100 # Compute Century-Item if year def day_of_week_string(day_index): days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] return days[day_index] # Prompt for the date…

Including 1752 is problematic, in the British Empire, it was the only year with 355 days, as September 3–13 were skipped when the Empire adopted the Gregorian calendar. These skipped days were a rolling problem across the world, when they were applied varied by country and religion of the recorder of historic accounts - they were by no means uniformly applied in the same year across the planet.

You are right. This code would not be accurate for many regions in the year they transitioned from the Julian to the Gregorian calendar

Re: Lewis Carroll – computing the day of the week for any given date (1887)

#90
post #57

Earlier quoted context omitted.

> which I have swutch to That's a past participle I've never seent before

Like the joke of the guy returning to Boston after being away for years; asks his cab driver "Do you know where I can get scrod" and the driver says "Sure, but I've never heard that in the past perfect before!"

Hmmm. When I heard that joke long ago, the driver said it was the pluperfect subjunctive. And here I took his word for it.
Post reply on HN