Python Challenge - Level 15
- Link: http://www.pythonchallenge.com/pc/return/uzi.html
- Username: huge
- Password: file
Problem

The image shows a calendar page for January with several critical clues:
- The year has a burnt hole showing
1and ending with6: year1xx6. - January 1 is a Thursday (hence January 26 is a Monday).
- February has 29 days, so it is a leap year.
- A red circle marks January 26.
- In HTML comment:
<!-- he ain't the youngest, he is the second --> - In HTML comment:
<!-- todo: buy flowers for tomorrow --> - Title:
whom?
Clues & Deduction
We need a leap year 1xx6 where January 26 was a Monday (or January 1 was a Thursday).
Among qualifying years:
1176,1356,1576,1756,1976- The youngest is 1976.
- The second youngest is 1756.
- The note says:
buy flowers for tomorrow(January 27, 1756). - Wolfgang Amadeus Mozart was born on January 27, 1756.
The answer is mozart.
Solution
Python
Using Python's standard calendar and datetime modules:
import calendar
import datetime
candidates = []
for year in range(1006, 2000, 10):
if calendar.isleap(year):
d = datetime.date(year, 1, 26)
if d.isoweekday() == 1: # Monday
candidates.append(year)
print("Candidates:", candidates)
# Candidates: [1176, 1356, 1576, 1756, 1976]
second_youngest = candidates[-2]
print("Second youngest:", second_youngest) # 1756
Go
Go's time package handles dates and weekdays:
package main
import (
"fmt"
"time"
)
func isLeapYear(year int) bool {
return (year%4 == 0 && year%100 != 0) || (year%400 == 0)
}
func main() {
var candidates []int
for year := 1006; year < 2000; year += 10 {
if isLeapYear(year) {
t := time.Date(year, time.January, 26, 0, 0, 0, 0, time.UTC)
if t.Weekday() == time.Monday {
candidates = append(candidates, year)
}
}
}
fmt.Println("Candidates:", candidates)
if len(candidates) >= 2 {
targetYear := candidates[len(candidates)-2]
fmt.Printf("Second youngest: %d\n", targetYear) // 1756
}
}
Rust
In Rust, we can compute the weekday and leap year directly without external crates using Zeller's congruence or Tomohiko Sakamoto's day-of-week algorithm, or with chrono:
fn is_leap_year(year: i32) -> bool {
(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)
}
// Sakamoto's algorithm for day of week (0 = Sunday, 1 = Monday, ...)
fn day_of_week(y: i32, m: i32, d: i32) -> i32 {
let t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];
let y = if m < 3 { y - 1 } else { y };
(y + y / 4 - y / 100 + y / 400 + t[(m - 1) as usize] + d) % 7
}
fn main() {
let mut candidates = Vec::new();
for year in (1006..2000).step_by(10) {
if is_leap_year(year) && day_of_week(year, 1, 26) == 1 {
candidates.push(year);
}
}
println!("Candidates: {:?}", candidates);
if candidates.len() >= 2 {
let second_youngest = candidates[candidates.len() - 2];
println!("Second youngest: {}", second_youngest); // 1756
}
}
Language Comparison
| Feature | Python | Go | Rust |
|---|---|---|---|
| Calendar / Date stdlib | calendar and datetime built-in with isleap() and .isoweekday() |
time.Date() and time.Weekday() in stdlib; leap year logic written manually |
No calendar/date in stdlib; use standard formula or chrono crate |
| Historical Dates | Proleptic Gregorian calendar extends back to year 1 | Proleptic Gregorian calendar; handles historical years without limitation | chrono::NaiveDate handles dates from year -262145 to +262144 |
| Step Iteration | range(1006, 2000, 10) |
Standard for year := 1006; year < 2000; year += 10 |
(1006..2000).step_by(10) |
Key insight: Python's calendar.isleap makes calendar riddles pleasant to solve quickly in a single script. Go's time package is surprisingly robust for historical dates, while Rust's zero-dependency pure arithmetic approach demonstrates that Gregorian weekday math is just a short, fast formula.
Next Level
Born on January 27, 1756 was Mozart:

