Live data from Hacker News

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

futilitycloset.com

31–40 of 109 posts

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

#31

Earlier quoted context omitted.

Second guessed myself and had to look up whether this was actually a word

Google says the correct term is, in fact, Nintendo Switch.

I assume it lets you know where to buy one as well.

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

#32

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]…

> partly because once you have the skill you find it's surprisingly useful.

A statement I find to be true in general.

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

#33
For the part that depends on the last two digits of the year I use a method that I've not seen anywhere else. It is algorithmically more work than Conway's method (Y + Y//4, where Y is the last two digits of the year and // is integer division rounding positive results down), but I think is easier for quick mental computation for most people.

Let Y = 10 T + U, i.e., T is the first digit of the two digit year and U is the second digit.

If T is even, the year part is:

  2 T + U       if U = 0, 1, 2, or 3
  2 T + U + 1   if U = 4, 5, 6, or 7
  2 T + U + 2   if U = 8 or 9
If T is odd:

  3 + 2 T + U       if U = 0 or 1
  3 + 2 T + U + 1   if U = 2, 3, 4, or 5
  3 + 2 T + U + 2   if U = 6, 7, 8 or 9
Algorithmically I compute it something like this:

  Compute 2 T + U
  If T is even
      Add 1 if T >= 4 and add another 1 if T >= 8
  else
      Add 3
      Add 1 if T >= 2 and add another 1 if T >= 6
Those add 1s come from the way leap years are distributed within decades. The 2 T + U takes into account any leap years when U = 0. The add 1s are to take care of the leap years that happen when U != 0. In even decades those occur at 4 and 8, and in odd decades they occur at 2 and 6.

Example: for 2024, T=2 and U=4. Mentally my train of thought would be:

  2 doubles to 4, plus 4 = 8 = 1 mod 7, even decade so add 1 for 4 
For that example there is not really easier than Conway's Y + Y//4, which would be 24 + 6 = 30 = 2 mod 7.

Example: for 2099, T = 9 and U = 9. Mentally that goes something like this:

  9 = 2 mod 7 doubles to 4, add 9 = 2 mod 7 giving 6
  T was odd so add 3 giving 9 = 2 mod 7
  T was odd so the so there were leap years at 2 and 6, which each add 1
  That gives us 4
I find that easier that Conway's 99 + 99/4. I can do that, and at decent speed, but I can make mistakes.

With my method you never have to deal with a number above 32, and that's only if you do no reductions mod 7 along the way. If you reduce mod 7 whenever you can you never have to deal with anything above 12.

Note: when reducing mod 7 along the way it is crucial to remember that whether you take the T is even case or the T is odd case depends on the actual value of T. E.g., when I am doing 2099 I reduce both T and U to 2 right away but first note that 9 is odd so will need to take the odd case.

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

#35

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]…

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

maybe you haven't liveth long enough

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

#36

Reading the article, I wandered into the difference of Old Style and New Style dates and what happened in 1752. From [1]: By the 18th century, the English legal year – used for legal, financial and other civil purposes – had for centuries begun on 25 March, or Lady Day.[13][i] Thus, for example, 24 March 1707 was immediately followed by 25 March 1708, while the day following 31 December 1708 was 1 January 1708, with…

The Romans also used the March-based year; that’s why February has fewer days and why October is literally the eighth month

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

#37
I'm having trouble following the algorithm for the month number.

From the article:

The Month-Item. — If it begins or ends with a vowel, subtract the number, denoting its place in the year, from 10. This, plus its number of days, gives the item for the following month. The item for January is ‘0’; for February or March (the 3rd month), ‘3’; for December (the 12th month), ’12.’ [So, for clarity, the required final numbers after division by 7 are January, 0; February, 3; March, 3; April, 6; May, 1; June, 4; July, 6; August 2; September, 5; October, 0; November, 3; and December, 5.]

My attempt to implement:

For January, the preceding month is December, which neither begins nor ends with a vowel, so I do not subtract 10. The days in December are 31, so 12+31 = 43 mod 7 = 1, not the 0 of the article.

For February, the preceding month is January, which ends in a vowel, so I subtract 1 from 10, giving 9, add the days in January 1+31 = 32 mod 7 = 4, not the 3 of the article.

For March, the preceding month is February, which ends in a vowel, so I subtract 2 from 10 giving 8 and add February's 28 days 8+28 = 36 mod 7 = 1, not the 3 of the article. Had I used a leap year 29 for the days in February at this step the result would be 2, which still does not match the article result. Since the article has a constant result for March, it is either always using 28 or always using 29 days in February.

For April, the preceding month is March, which neither begins nor ends in a vowel so I do not subtract it from 10. 31 days in March gives 3+31 = 34 mod 7 = 6, which does match the article result.

For May, the preceding month is April, which starts with a vowel, so I subtract its position from 10, 10-4 = 6, add April's 30 days 6+30 = 36 mod 7 = 1 which does match the article.

For June, the preceding month is May, ending in a vowel, so I subtract May's 5 from 10, and adding May's 31 days gives 5+31= 36 mod 7 = 1 which does not match the article.

This should suffice to illustrate my misunderstanding; what have I got wrong?

[edit: typos]

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

#40
post #10

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 am struggling to understand the advantages over the Lewis Carroll method, which I find very simple and quick. It seems to add quite a lot of complexity.

I think it's unreasonable for you to have been downvoted, and I've given you an upvote to do what I can to balance that. Expressing confusion over something like this is perfectly reasonable.
Post reply on HN