Thursday, September 2, 2010

"This august had 5 sundays, 5 mondays, 5 tuesdays..."

"...and this event takes place every 823 years..." - said the fb update of one of my friends. This meme had then a viral clause attached to it so to ensure its replication - something about money, happiness and all that.

However, it's not the viral clause that caught my attention - but, rather, the "takes place every 823 years" part of the meme, which looked suspiciously fishy - and I decided to make a quick write-up as an after-lunch exercise.

Intuitively, it is simple to see that every August will have 5 of *some* three consecutive days of the week - simply because there are 31 days in august, and there are 7 days in a week - and 31 modulo 7 is three. And the days are consecutive - so this leaves us with 7 combinations of "triples".

The number of days modulo 7 from the "previous august" will give us the shift within days of the week year-over-year. For an ordinary year, it's 1 day (365%7), and for a leap year it is 2 days.

So, if we have the five of sunday-monday-tuesday this august, then the next occurence will be in 2016. If it was not a leap year - then we "overshoot" the target, and need to walk another 6 years. So the next occurence will be in 2021 (11 years after).

Then in 2027 (6 years), 2032 (5 years), 2038 (6 years), 2049 (11 years), 2055 (6 years), 2060 (5 years), 2066 (6 years), 2077 (11 years), and so on.

With the differences forming a nice series: 11-6-5-6-11-...

The period of this sequence is 28 == 11+6+5+6. Which happens to be divisible by 7 (number of days of week in a week) and by 4 (The usual interval between the leap years).

We did not take into the account the years of 2100, 2200, 2300, 2400 - I leave it as an exercise to the reader.

In conclusion - this was a well-crafted meme. It had not one but two replication mechanisms, that were targeting different people. I guess I can say I fell the prey of it. :-)