const DAYS: [u64; 12] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; const fn get_sum_of_digits(mut n: u64) -> u64 { let mut sum = 0; while n > 0 { sum += n % 10; n /= 10; } sum } fn main() { let answer = DAYS .iter() .enumerate() .flat_map(|(m, &n)| (1..=n).map(|d| (m as u64 + 1, d)).collect::>()) .filter(|&(m, d)| get_sum_of_digits(d) == m) .count(); println!("{}", answer); }