Archimerged has decided to start blogging again on more subjects. Today he gives his version of Conway’s “Doomsday” algorithm. (Google for Conway Doomsday to find other treatments, or see the Wikipedia article). He also talks a little about Asperger’s syndrome and mood disorders and his dog down at the bottom of the post. Since he uses a slightly different definition of Doomsday, he has decided to rename it. Googling various possibilities (Fixedday, Fixday, Lastday, Lassday, Lasday, Postday, Markday, Seedday, etc.) for a name without too many alternate meanings, he has just now thought of Keyday, which seems superior to all of the above.
The lead paragraphs in the Wikipedia article are actually very good (the rest is too):
For any year, Doomsday is the day of the week on which the last day of February falls. It is also the day of the week of 4/4, 6/6, 8/8, 10/10 and 12/12, as well as 5/9, 9/5, 7/11, and 11/7.
It is a convenient way of characterizing each of the 7 possible calendars for the months March – December. Only for the calendar of January and February is a further distinction between common year and leap year needed. Alternatively the fixed connection with the Doomsday of the previous year is used for these two months.
Anyway, it isn’t hard to figure the weekday of any date in your head if you learn the technique a step at a time. Archimerged recommends this order:
First, learn that Conway’s Doomsday is the same particular weekday every week of any given calendar year: the last day of February and every 7 days before and after. Archimerged’s Keyday always falls on February 27, one or two days later on the last day of February, and every 7 days up to and including February 27 of the next year. So Keyday always falls on December 12, January 9, February 6 (note the progression due to December and January both having 31 days), while Doomsdays in January and February depend on whether it’s leap year or not. But Doomsday is the same weekday all year, while you have to remember that in January and February Keyday is the same weekday as last year’s Doomsday. So Archimerged writes of the Doomsday of a year, not the Keyday, because any given Keyday applies to the March to February year.
The Keyday rule makes it clear that in regular years, Keyday advances by one weekday on February 28, while in leap years, Keyday advances by two weekdays on February 29. February 27 was Keyday, and February 28 or 29 is also Keyday — the new year always advances Keyday by one or two weekdays on the last of February. Doomsday advances on January 1 so January 2 is not a Doomsday. A year always has 52 Doomsdays and 53 Keydays.
The key to Doomsday and Keyday is that they always fall on the same day of the month in March through December. Conway gives this mnemonic: “He works nine to five at the Seven-Eleven.” Doomsday falls on 4/4, 6/6, 8/8, 10/10, 12/12 (and Keyday on 1/9 and 2/6), and on 9/5 and 7/11 as well as 5/9 and 11/7. Doomsday falls on 1/10 or 1/11 and on 2/7 or 2/8 depending on leap year. (Contrary to popular belief, and with disrespect only to politicians and other opportunistic greedy pigs, 9/11 was not a Doomsday). That covers all months except March, and you know Doomsday is the last day of February so it must fall on March 7, 14, 21, and 28. Doomsday also falls at a fixed offset from certain holidays: July 4 is a Doomsday, Christmas is the day before Doomsday, New Year’s day is the day before Keyday, and Veteran’s day 11/11 is always 4 days after Doomsday 11/7 (duh). The other U.S. Federal holidays always fall on Monday (M. L. King day, President’s day, Labor day, Columbus day, Veteran’s day) or Thursday (Thanksgiving day). Archimerged remembers the magazine insert (probably Parade) in the Sunday paper which urged people to write to Congress asking for holidays to fall on Monday.
The first Keyday of the month is August 1, January and May 2, October 3, April and July 4, September and December 5, February and June 6, March and November 7. August and October are the only months which do not share a Keyday with another month. This analysis comes out different for Doomsday and depends on leap year.
Next, learn to add and subtract small numbers from weekdays to get weekdays. This is useful even if you don’t finish the rest. Start with 3 (no counting on your fingers!) and work up to adding and subtracting 1 to 31. When you’re done you know instantly that Wednesday plus 31 is Wednesday plus 3, Saturday; Wednesday minus 31 is always Sunday; Sunday plus 13 is the same as Sunday minus 1, etc., etc. Archimerged believes this is superior to using a code for days like 0 for Sunday, 1 for Monday, adding numbers, taking the remainder after dividing by 7, and translating back to weekdays. (They ought to teach this number plus weekday gives weekday addition table in elementary school).
Third, in order to be able to use this knowledge, memorize the current year’s Doomsday. In 2006, Doomsday is Tuesday. Let this settle for a while and practice figuring weekdays for dates of this year.
After you get good at the current year, learn this bit of trivia: the last day of February, 1900, was Wednesday the 28th, and the last day of February, 2000, was Tuesday the 29th. Conway gives “We in dis day” as a mnemonic for 1900, since most people alive today were born in the 20th century.
Some other day, learn that the last day of February is Tuesday the 29th in 2000, 2400, 2800, etc. and in Rome also 1600 (but not most other places). Also the last day of February is Wednesday the 28th in 1900, 2300, etc., Friday the 28th in 1800, 2200, etc., and Sunday the 28th in 1700 (in Rome), 2100, etc. The last day of February never falls on Monday, Thursday, or Saturday on century years. It is for this reason that over the long haul, the 13th of any Gregorian month is more likely to be Friday than any other day.
On yet some other day, figure out the rule for Julian century years and memorize the dates when different countries switched. (You are an Aspie, aren’t you?)
But before learning all the other centuries, learn to figure what weekday Doomsday falls on for any given year of the century. The most obvious approach is to note that every year adds one weekday and every leap year adds an additional weekday. Therefore, add the two digit year to the century Doomsday (you did learn to add numbers to weekdays, right?). Then correct for leap years by adding the number of leap years since the century year (and not counting the century year, which as purists know is the last year of the previous century anyway). That is, given year C*100+Y, add Y + [Y/4] to Doomsday of C*100, where [4/4] = [5/4] = [6/4] = [7/4] = 1, etc. This applies for for all C, but Doomsday of the century year depends on the calendar (Gregorian or Julian).
Writing D(’00) for the century year Doomsday and using addition of numbers to weekdays, the general rule is: for Y in 0 .. 99,
- D(’00+Y) = D(’00) + Y + [Y/4].
A shortcut is to figure the number of dozens in the two-digit year. Add the number of dozens plus the remaining years plus 1 or 2 leap days to the century’s Doomsday.
For Y in 0 … 11, D(’00+Y) = D(’00) + Y + [Y/4], and
- D(’12+Y) = D(’00+Y) + 1,
- D(’24+Y) = D(’00+Y) + 2,
- D(’36+Y) = D(’00+Y) + 3,
- D(’48+Y) = D(’00+Y) – 3,
- D(’60+Y) = D(’00+Y) – 2,
- D(’72+Y) = D(’00+Y) – 1,
- D(’84+Y) = D(’00+Y), and
- D(’96+Y) = D(’00+Y) + 1 (for Y in 0 … 3 only).
A different shortcut is to first take the remainder after division by 28. Subtract 28, 56, or 84 from Y and then figure Doomsday for the remainder. If you are very good at doing the years ’00 to ’27, this lets you extend your skill to the rest of the century at the expense of an extra subtraction.
For Y in 0 … 27, D(’00+Y) = D(’00) + Y + [Y/4], and
- D(’28+Y) = D(’00+Y),
- D(’56+Y) = D(’00+Y), and
- D(’84+Y) = D(’00+Y) (for Y in 0 … 15 only).
To cover the first 28 years, the dozens rule expands as follows:For Y in 0 … 3,
- D(’00+Y) = D(’00) + Y (because [Y/4] is 0),
- D(’12+Y) = D(’00) + Y + 1 (because [Y/4] is 0),
- D(’24+Y) = D(’00) + Y + 2 (because [Y/4] is 0).
For Y in 4 … 7,
- D(’00+Y) = D(’00) + Y + 1 (because [Y/4] is 1),
- D(’12+Y) = D(’00) + Y + 2 (because [Y/4] is 1).
For Y in 8 … 12,
- D(’00+Y) = D(’00) + Y + 2 (because [Y/4] is 2),
- D(’12+Y) = D(’00) + Y + 3 (because [Y/4] is 2).
There is also a completely different method: you can learn which years of a century have the same Doomsday as the century year, i.e., the years ’00 + Y where Y + [Y / 4] is a multiple of 7. The pattern repeats every 28 years, of course.
Here is the complete table, including the leap years ’12, ’40, ’68, and ’96 in which the century Doomsday falls on February 28 while Doomsday of course falls on February 29.
- D(’00) = D(’28) = D(’56) = D(’84) = D(’00),
- D(’06) = D(’34) = D(’62) = D(’90) = D(’00),
- D(’12) = D(’40) = D(’68) = D(’96) = D(’00) + 1,
- D(’17) = D(’45) = D(’73) = D(’00),
- D(’23) = D(’51) = D(’79) = D(’00).
To use the above facts, memorize the list of years. Given year Y, find the largest year T in the table less than Y. Figure Y – T, which cannot be more than six. Figure how many of the years T+1, T+2, … Y are leap years. This can be zero, one, or two. Then,
- D(Y) = D(’00) + (one if T is ’12, ’40, ’68, or ’96) + (Y-T) + (the number of leap years in T+1 … Y).
With practice, this may be a little faster than adding the number of dozens, the number of years left over, and the number of leap years left over, especially when Y = T. For example, Y = ’51 is in the table so D(’51) = D(’00). Using dozens, ’48 is 4 dozens past ’00, and ’51 is 3 years and no leap years past ’48, giving D(’51) = D(’00) + 4 + 3 = D(’00).
So, why did Archimerged spend most of a day writing this? Just like the girl with the spoons in that documentary, practicing a skill like this is soothing. Archimerged suffers from some kind of mood disorder in addition to believing he has Asperger’s syndrome even if the mental health people he has talked to don’t see how he meets the DSM critera. Antidepressants help but have not really fixed it after several years of use. This suggests that the diagnosis of major depression is wrong. A long history of unfinished projects may suggest a new diagnosis of some kind of bipolar disorder, but the treatment there may be worse than the disease. It can be very hard to ignore mood and act strictly logically, and mood disorder means it is harder than usual, but drugs are still quite imprecise tools and Archimerged frankly doesn’t trust them.
(Archimerged gives up on second person seeing as his dog is male…) Why do people and animals do what they do? Mood must have a lot to do with it. People can use abstract thought to adjust what mood leads them to do, while animals can’t. I observe my dog remembering: when he has encountered a situation before, he remembers what happened. I believe this directly controls his mood. For a long time he didn’t connect taking the leash down from the hook and going out. I was trying also to always say “out,” but sometimes I would say “out” but then not be able to go immediately. But I never took the leash down until I was actually ready. He might go down the steps and get stranded. (He can’t climb back up due to patella malformation). Then he feels bad, and howls. So I think when the circumstances match up, he remembers how he felt after going down, and stays at the top of the steps. Now when I say “out” he doesn’t really believe me until I take the leash down.
So Archimerged looks at this and say the dog’s brain recongnizes a pattern including many factors. The result is a mood (excitement or lonliness) and a prediction of future events (being taken out or being stranded at the bottom of the stairs). Archimerged thinks people’s brains work this way too. In a mood disorder, the pattern recognition responds inaccurately causing strong mood effects that do not match reality. Maybe there is a way to counteract these responses without using drugs that have side effects like tardive dyskinesia or lithium poisoning.