We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
(Python specific) The python datetime module cannot calculate weekday for large years. Test cases 4 and above will fail.
The years and days of the week are exactly the same every 2800 days. You could use this to get around the datetime lookup limitation but be careful not to just mod every year by 2800. Instead take the difference of start and end, mod the start and then add the difference back to the first to get the new end year.
Best: Zeller's Congruence gives a nice algorithm that returns the day of the week for any given date. Test the first of every month within the interval using Zeller's algorithm. This sidesteps the two points above.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #19: Counting Sundays
You are viewing a single comment's thread. Return to all comments →
Lessons: