I think this thread is somewhat similar to an existing one, so I want to clarify that this is specifically about calculating the year code when performing calendar calculations. I’ve found that this step has proven to be the most troublesome, both for myself and from what I’ve read from others, so I wanted to provide a list of the possible ways this can be accomplished. Hopefully having them all in one place will help others who are trying to get faster at this part of calendar calculation.
Preface: This post will assume the reader knows how to perform calendar calculation, and I will also assume you are using a method in which the year code for 00 is 0. Of course, if you use any method which uses a code of the year (specifically, the last two digits of the year), then this can be adapted to suit your needs. With that being said, let’s get into it.
Here are the methods I will discuss:
- Brute force
- Major/Minor leap years
- Partition-and-halve
- Reduction
- Memory
Afterwards, I will give a brief summary with my thoughts on the methods and which ones I would recommend.
Brute force
This method is straightforward enough. Given a 2-digit year, divide it by 4 (casting out any remainder), add this to the original year number, and reduce mod 7. Here’s an example with 53:
53 → 53 + 13 = 66 → 3
Here we added 13 because 53/4 = 13 with a remainder of 1.
I think this is the method most people start out with, and while it certainly is simple enough, it does not lend itself well to speed. This causes a lot of people to switch to the next method.
Major/Minor Leap Years
This is an improvement over the previous method, which is easy to understand with some modular arithmetic. We start by noting that any year of the form y = 12*n will have year code n. These are called major leap years. Every other leap year is called a minor leap year. The process is to calculate the year code by traversing through major/minor leap years, as follows for the 53 example:
Closest major leap year <= 53 is 48 (year code 48/12 = 4).
Traverse up minor leap years, adding 5 for each: Now we are at 52, year code = 4 + 5 = 9.
Traverse the remaining years, adding 1 for each: Now we reach 53, year code = 9 + 1 = 10.
Final answer: 10 mod 7 = 3.
Partition and halve
This method is already detailed quite well in this post: New Approach To Calculating Year Keys.
Here is a brief explanation though:
Rewrite the year in the form 4a + b, where b <= 3.
Change this to 2a - b and evaluate, call this t.
Count up from t to the nearest multiple of 7. The amount you counted up is the result.
Example: 53 = 4*13 + 1 → 2*13 - 1 = 25.
28 - 25 = 3, so 3 is our result.
Reduction
This method recognizes that every 28 years, the year codes repeat. The first step is to reduce the year given mod 28 by subtracting either 28, 56, or 84 (or 0). From there, each of the leap year codes from 0-27 (4, 8, 12, 16, 20, 24) can be memorized. This allows you to quickly count up to the given year without thinking about major/minor leap years.
Example: 53 - 28 = 25. 24 has year code 2, so 25 has year code 2 + 1 = 3.
Memory (MPRL)
This is also detailed in a forum post: Do you use "reverse lookup"? #MPRL
The idea is simply to have a memory palace for years which have a certain year code: all those with year code 0 are in one memory palace, all with year code 1 are in another, and so on.
Example: 53 → lime → lime is in a swimming pool (memory palace for wednesday) → 3.
Summary
Brute force is certainly the easiest to understand, but with some modular arithmetic the other calculation techniques can also be followed fairly easily. I personally was never fond of the major/minor leap year method, but I found parition-and-halve to be quite nice as it provides the answer already reduced mod 7. Now, I really like reduction as I’ve found it to be even faster than partition-and-halve.
All that being said, MPRL will certainly lend itself the most to speed, as there is no calculation to be done. For people who are dedicated to calendar calculation, this is the avenue to pursue. If you are like me and don’t have the time/energy/commitment to spend on calendar calculation, I would encourage you to try partition-and-halve or reduction, as those are the two which I have found to have the highest ROI.
I’m happy to hear your thoughts, or what method you use which isn’t on this list!