fn main() { let t:[u8;12] = [31,28,31,30,31,30,31,31,30,31,30,31]; let mut c = 0; for (m, d) in t.iter().enumerate() { for i in 1..(d+1) { let s = i.to_string().chars() .map(|c|c.to_string().parse::().ok().unwrap()).sum(); if m+1 == s { c += 1; } } } println!("{}", c); }