use std::collections::BinaryHeap; fn main() { let input = lib::read_input(1); part1(&input); part2(&input); } fn part1(input: &str) { let ans: usize = input .split("\n\n") .map(|elf| { elf.split("\n") .flat_map(|item| item.parse::().ok()) .sum() }) .max() .unwrap(); println!("{}", ans); } fn part2(input: &str) { let mut heap: BinaryHeap = input .split("\n\n") .map(|elf| { elf.split("\n") .flat_map(|item| item.parse::().ok()) .sum() }) .collect(); println!( "{}", heap.pop().unwrap() + heap.pop().unwrap() + heap.pop().unwrap() ); }