AoC2022/d01/src/a2v2.rs
2022-12-11 18:06:33 +01:00

20 lines
376 B
Rust

pub fn run(inp :Vec<String>) {
let mut v :Vec<i32> = vec![];
inp.split(|line| line.is_empty()).for_each(|vector|{
v.push(vector.iter().map(|s| s.parse::<i32>().unwrap()).sum());
});
let mut sum = 0;
for _ in 0..3 {
let e = v.iter_mut().max().unwrap();
sum += *e;
*e = 0;
}
println!("a2v2: {}", sum);
}