FiveThirtyEight’s puzzle feature, the Riddler, had a puzzle this week called Don’t throw out that calendar!. (Spoilers below; also, I’m delaying posting this until after the submission period for solutions ends.). This puzzle is due to Ben Zimmer.

Sometime in the 21st century, the following conversation takes place:

“Don’t throw out that calendar! You could reuse it in the future, when the days and dates on the calendar match up again.”

“OK, but that won’t happen for a long time. Forty years, in fact.”

“You’re right! In fact, this calendar has never had a 40-year gap before.”

What year is it?

We can start by observing that there are 14 possible calendars. To know what calendar we can use in a given year, we have to know whether it’s a common (non-leap) or leap year, and the day of the week of one particular day. Let’s pay attention to what John Conway called “Doomsday”, i. e. the last day of February (February 28 in common years, and February 29 in leap years). Doomsday moves forward one day in the week each year, except two days in each leap year – so, for example, Doomsday (February 28) 2015 was a Saturday, Doomsday (February 29) 2016 was a Monday, and Doomsday (February 28) 2017 will be a Tuesday.

So let’s consider when a 40-year gap will happen. A 40-year gap can’t begin with a common year. Say the year Y is the year after a leap year; then Doomsday of Y+6 will be the same as Doomsday of Y, since over those six years Doomsday will move forward six days in the week, plus one day for the leap year. If Y is two or three years after a leap year, then Y + 11 and Y will have the same Doomsday – Doomsday moves forward 11 days, plus three for the leap years. (This is basically cribbed from the calendar FAQ.

The exception is if Y is very near the end of a century that isn’t divisible by 400 – near enough that one of the otherwise intervening leap years would be a common year. In any of these cases Y and Y + 12 share a calendar – there are two intervening leap years.

(In most cases Y and Y + 28 share a calendar – that is, if no end-of-century common year intervenes. But we’d still have to do the casework anyway.)

So we must be in a leap year. But a 40-year gap, from Y to Y + 40, should lead to a Doomsday being one day later (40 + 10 = 50, which is one more than a multiple of seven) We must be in a leap year for which there are only NINE leap years in the next 40 – i. e. we’re in one of 2064, 2068, …, 2096 – since 2100 isn’t a leap year. But the calendars 2064 and 2068 will be repeated in 2092 and 2096 (28 years later, with 7 leap years), and 2092 and 2096 will be repeated twelve years later (with two leap years). So we must be in one of the five years 2072, 2076, 2080, 2084, and 2088.

Which one is it? See the note “You’re right! In fact, this calendar has never had a 40-year gap before.” By the same reasoning as above, 40-year gaps in the past could have only happened in starting in one of the leap years 1672-1688, 1772-1788, 1872-1888, since the Gregorian calendar – which insituted our current leap-year policy and thus the nine-in-forty loophole started in 1582. (1600 and 2000 were leap years, so 15xx and 19xx candidates are out.)

Doomsday in 1672 in the Gregorian calendar was Monday. I cheated by looking it up. For example you can type `ncal -sFR 1672` at your friendly Unix prompt, where “FR” is the country code for France, a country that adopted the Gregorian calendar at the beginning. Honestly, it doesn’t matter what day of the week Doomsday in 1672 is, only the relationships between the Doomsdays. In 1772 Doomsday is Saturday (124 days later in the week, that is, 100 years plus 24 leap years); in 1872 it’s Thursday. So we can work out the doomsdays for each leap year. These are:

1672 through 1688: Mon, Sat, Thu, Tue, Sun

1772 through 1788: Sat, Thu, Tue, Sun, Fri

1872 through 1888: Thu, Tue, Sun, Fri, Wed

2072 through 2088: Mon, Sat, Thu, Tue, Sun

All seven days of the week occur here, so the puzzle seems to be broken. But if we’re in a country which switched calendars after 1672 but before 1772 – like, say, Great Britain and its colonies, which changed over in 1752 – then the doomsday-Monday calendar won’t have occurred yet but the other six have. (Again from the calendar FAQ), we could also be pretty much anywhere else in Protestant-dominated Europe or colonies thereof.) The answer is 2072.