300 - Maya Calendar


Difficulty : easy

Solution Description :

Ad Hoc Problem

First, determine how many days have passed since the beginning of
time. This is of course year*365 + (month-1)*20 + day. Call this
quantity X.

The Tzolkin date is:

Year - X / 260
Day - (X % 13) + 1
if Day > 0 then X=X+1
Month - X % 20

There's an extra one on the day because the days are 1-indexed in
Tzolkin, but 0-indexed in Haab.