Live data from Hacker News

Calculate the day of the week for any date in your head

rudy.ca

41–50 of 68 posts

Re: Calculate the day of the week for any date in your head

#41
post #25

If not for religious groups, we could have had World Calendar and all this would be unnecessary: https://en.m.wikipedia.org/wiki/World_Calendar .

Yea nope. Leap days not having a weekday? How would that even work?

Every once in a while there would be a day called Leap Day.

Re: Calculate the day of the week for any date in your head

#42

If not for religious groups, we could have had World Calendar and all this would be unnecessary: https://en.m.wikipedia.org/wiki/World_Calendar .

Why does the week start on a Sunday in that calendar?

In some countries Sunday is considered the first day of the week, which is quite strange for me, as here it's Monday.

Do Americans, for example, feel like "a new week has started" on Sunday morning? For me Saturday and Sunday feel as one block, it's weird to imagine a separation in there.

But perhaps someone who grows up with that calendar feels like Saturday is end-of-the-week winding down, and Sunday is a start-of-the-fresh-week "warmup" day.

Re: Calculate the day of the week for any date in your head

#43
post #39

Earlier quoted context omitted.

Got tricked during a CS course with this. I bet a lot of the people in that class will remember the full rule. It then came back on the final.

What do you mean, “tricked”? The method is original to me and I don’t think it has spread very far. Is there a Gregorian calendar year for which the GP algorithm gives the wrong result?

The two methods are exactly - exactly - the same. Just different ways of phrasing. Don't fool yourself.

Re: Calculate the day of the week for any date in your head

#44

For all but the most basic details my rule is that if I have to remember it, the system is broken. I know a small handful of passwords off the top of my head, a few email addresses, my wife's and my phone numbers, and the phone number of my home during childhood. (I'm obviously exaggerating, you know, for dramatic effect.) This trick requires so many mnemonic devices that it makes my head spin. It's still impressive…

This comment made me take a brief inventory of some of the systems I have internalized to the point where I don't think about them as being memorized: the rules of the road while driving, the conventions of UNIX-style commands, unit conversions, hotkeys in (and across) applications, how street addresses and road navigation works, how to use a search engine, how to compose a sentence in English, and so on.

At some point in my life, all of these seemed needlessly complex and arbitrary to me, but they don't anymore (at least unless I think too hard about them). I don't think about them unless I have to teach them to someone else, at which point I start thinking about how seriously broken they are.

I suppose that if I needed to get the day of the week from any date in history, and used this algorithm often enough, I'd eventually think of it as something I didn't have to memorize either.

Re: Calculate the day of the week for any date in your head

#45
post #43

Earlier quoted context omitted.

What do you mean, “tricked”? The method is original to me and I don’t think it has spread very far. Is there a Gregorian calendar year for which the GP algorithm gives the wrong result?

The two methods are exactly - exactly - the same. Just different ways of phrasing. Don't fool yourself.

The standard method and mine give the same result, and I believe that mine is simpler to carry out in your head.

In what way do you believe that I am fooling myself?

Re: Calculate the day of the week for any date in your head

#46
post #12
post #7

Earlier quoted context omitted.

You only need to remember 5 things: - For 2020, the doomsday is Saturday. All the dates below are doomsdays (So this year they are all Saturdays): - 4/4, 6/6, 8/8, 10/10, 12/12, easy enough - 9/5, 5/9, 7/11, 11/7 (9-to-5 at 7-11) - 0th of March (last day of February) - 3rd of January for non-leap years, and 4th of January for leap years. So this year the 4th is Saturday. And to calculate dates: mod 7. So e.g. 7th of…

You can skip the leap year info completely if you consider both January and February as belonging to the previous year. That makes sense as the additional day (Feb 29) is at the end of Februry. Last year Pi Day was Thursday, this year Saturday. So the general rule then is: March 14th, April 4th, May 9th, June 6th, July 11th, August 8th, September 5th, October 10th, November 7th, December 12th, January 2nd, February 6…

But why do you call them Pi-Days? Pi Day is 3/14 because that's somewhat similar to 3.14, which is Pi to 3 significant digits..

Re: Calculate the day of the week for any date in your head

#47
post #43

Earlier quoted context omitted.

The two methods are exactly - exactly - the same. Just different ways of phrasing. Don't fool yourself.

The standard method and mine give the same result, and I believe that mine is simpler to carry out in your head. In what way do you believe that I am fooling myself?

Not so much as fooling yourself, but I agree with the OP your method isnt really 'original' in the sense that it's indeed exactly the same as the 'standard' one, just a tad different in how you explain the math. E.g. 'if not ending in 00 throw away...' is really just the same thing as 'except when divisable by 100'.

Re: Calculate the day of the week for any date in your head

#48
post #47

Earlier quoted context omitted.

The standard method and mine give the same result, and I believe that mine is simpler to carry out in your head. In what way do you believe that I am fooling myself?

Not so much as fooling yourself, but I agree with the OP your method isnt really 'original' in the sense that it's indeed exactly the same as the 'standard' one, just a tad different in how you explain the math. E.g. 'if not ending in 00 throw away...' is really just the same thing as 'except when divisable by 100'.

To add to your comment, being divisable by 400 is also the same thing as throwing away the 00 and checking the remaining is divisable by 4. One explanation is just a rephrasing of the other for the exact same method.

Re: Calculate the day of the week for any date in your head

#49
post #20

Earlier quoted context omitted.

To go from "any" century, you can also memorize "2053", which is the days in a 4-year cycle: 2000 = 2 = tuesday; 2100 = 0 = sunday; 2200 = 5 = friday; 2300 = 3 = wednesday. For years other than the centuries, we need to add an offset. Given the year CCXX, we have: (a, b) = divmod(XX, 12) c = b // 4 offset = a + b + c doomsday = start + offset E.g., for 2020 (XX == 20) we get: start = 2 # from the "2053" rule (a, b) =…

The "add 11" trick in my comment is easier to remember and apply than dividing by 12 and taking remainders.

I like my current method [1], while only requires addition, doubling, and a couple of conditional increments or additions. Even if you don't bother doing any mod 7 reduction along the way, you never have to deal with a number above 32.

With both divide by 12 and odd 11, I would find myself occasionally making a goof when dealing with years near the end of centuries.

[1] https://news.ycombinator.com/item?id=21926543

Re: Calculate the day of the week for any date in your head

#50
post #12

Earlier quoted context omitted.

You can skip the leap year info completely if you consider both January and February as belonging to the previous year. That makes sense as the additional day (Feb 29) is at the end of Februry. Last year Pi Day was Thursday, this year Saturday. So the general rule then is: March 14th, April 4th, May 9th, June 6th, July 11th, August 8th, September 5th, October 10th, November 7th, December 12th, January 2nd, February 6…

But why do you call them Pi-Days? Pi Day is 3/14 because that's somewhat similar to 3.14, which is Pi to 3 significant digits..

They are the same weekday as 3/14 and it makes a little more sense than 'Doomsday', which the article chooses.
Post reply on HN