use crate::Solution;
problem!(Problem0019, 19, "Counting Sundays");
impl Solution for Problem0019 {
fn solve(&self) -> String {
const DAYS_IN_MONTH: [u32; 13] = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
let mut year = 1900;
let mut month = 1;
let mut day = 1;
let mut sundays = 0;
while year <= 2000 {
if (day % 7 == 0) && (year != 1900) {
sundays += 1;
}
day += DAYS_IN_MONTH[month as usize];
if month == 2 && (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
day += 1;
} else if month == 12 {
month = 0;
year += 1;
}
month += 1;
}
sundays.to_string()
}
}