Yesterday got a calendar for 2016. An interesting question came up my mind: When can I reuse this calendar, and for which year can I reuse which old calendar?
The 1st January 2015 was a Thursday. The same day in 2016 is a Friday. Once you follow this pattery you will quickly recognize that the base period of seven years is disrupted by leap years.
It quickly turns out that for some years it takes decades until you can reuse a calendar: 2016 is a leap yer, so you can not reuse it for 2044.
However, there’s a neat quirk that is currently unimplemented in online services like whencanireusethiscalendar.com: You can partially reuse a calendar.
The reason that two calendars don’t match is often a leap day in one of them. Quite often, however, they match either up to the leap day or starting from the day after the leap day. We call these years partial reuse years (A) and (B) respectively. Once you consider this option (i.e. you interchange the calendar somewhere around the leap day, assuming we have a both a (A) and a (B) reusable calendar for one year) you will be able to reuse calendars — especially leap-year calendars like 2016.
Based on this insight, I wrote a simple brute-force python script using only core libraries. You can simply call it on the command line with the year of the calendar you