aoc2022/examples/day01_1.rs
2022-12-01 00:25:40 -05:00

17 lines
389 B
Rust

fn main() -> Result<(), Box<dyn std::error::Error>> {
let lines = std::io::stdin().lines();
let mut max = 0;
let mut elf = 0;
for line in lines {
let line = line?;
if line.trim().is_empty() {
max = max.max(elf);
elf = 0;
} else {
elf += line.parse::<i32>()?;
}
}
println!("{}", max);
Ok(())
}