Re:Calculate the day of the week for any date in your head
by rovr138 on Wednesday January 01, 2020 @11:51AM
(#21928886)
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.
Re:Calculate the day of the week for any date in your head
by bumbledraven on Wednesday January 01, 2020 @11:58AM
(#21928928)
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?
Re:Calculate the day of the week for any date in your head
by htfu on Wednesday January 01, 2020 @12:07PM
(#21928991)
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
by firethief on Thursday January 02, 2020 @11:57AM
(#21937053)
It's algebraically equivalent, but it's not the same procedure. The insight in Bumbledraven's Algorithm is that by factoring out an unconditionally-performed mod-4 step, the problem can be reduced to two cases.
Re:Calculate the day of the week for any date in your head
by bumbledraven on Wednesday January 01, 2020 @12:16PM
(#21929034)
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
by stinos on Wednesday January 01, 2020 @12:33PM
(#21929147)
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
by jolmg on Wednesday January 01, 2020 @12:53PM
(#21929312)
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.
If the last two digits of the year are 00, throw them away and keep only the first two digits. Otherwise, keep only the last two digits. The year is a leap year if what you kept is divisible by 4.
Examples:
- The year 1705 does not end in 00, so throw away 17 and keep 05. 05 is not divisible by 4, so 1705 is not a leap year.
- The year 2000 ends in 00, so throw away 00 and keep 20. 20 is divisible by 4, so 2000 is a leap year.
The standard method [2] is more complicated:
> Years that are divisible by four are leap years, with the exception of years that are divisible by 100, which are not leap years, and with the final exception of years divisible by 400, which are.
[1] https://twitter.com/jordancurve/status/1012203999716618240
[2] https://www.theguardian.com/science/2011/feb/28/leap-year-al...