Another fantastic resource is Boris Kordemsky's book The Moscow Puzzles:
https://www.amazon.com/Moscow-Puzzles-Mathematical-Recreatio...
https://www.amazon.com/Moscow-Puzzles-Mathematical-Recreatio...
Does New Year's Day fall more often on a Saturday or a Sunday?
Such a simple puzzle with to (then) me such depth of knowledge to uncover the answer.Do you recall the solution? It seems like a tricky problem. No approach occurs to me aside from a brute force analysis of the 400 year Gregorian calendar cycle, accounting for the complete leap year rules (under which, e.g., 1900 was not a leap year but 2000 was).
const counts = Array(7).fill(0);
for (let year = 2000; year < 2400; year++) {
counts[new Date(year, 0, 1).getDay()]++;
}
console.log(`Number of Saturdays: ${counts[6]}; Number of Sundays: ${counts[0]}`);
Output: Number of Saturdays: 56; Number of Sundays: 58
Note: getDay() returns 0 for Sunday and 6 for Saturday (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...).To check, see this 5-line brute-force calculation in JavaScript: https://news.ycombinator.com/item?id=42024474