AoC2022/d01/src/a1.rs

30 lines
445 B
Rust
Raw Normal View History

2022-12-11 18:06:33 +01:00
pub fn run(inp :Vec<String>) {
let mut max = 0;
let mut curr_max = 0;
inp.iter().for_each(|elem| {
let number = elem.parse::<i32>();
match number {
Ok(n) => {
curr_max += n;
}
Err(_) => {
curr_max = 0;
}
}
if curr_max > max {
max = curr_max;
}
});
println!("a1: {}", max);
}