use std::{ fs::File, io::{BufRead, BufReader}, iter, }; fn main() -> () { let path = "input.txt"; let input = File::open(path).unwrap(); let buf = BufReader::new(input); let mut top = [0; 3]; let mut cur = 0; for line in buf.lines().chain(iter::once(Ok(String::from("")))) { let line = line.unwrap(); if line == "" { top[0] = top[0].max(cur); top.sort(); cur = 0; } else { cur += line.parse::().unwrap(); } } println!("{}", top.iter().fold(0, |acc, el| { acc + el })); }