use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day1)] pub fn input_generator(input: &str) -> Vec> { input .lines() .collect::>() .split(|el| el == &"") .map(|list| { list.iter() .map(|el| el.parse::().unwrap()) .collect::>() }) .collect::>() } #[aoc(day1, part1)] pub fn solve_part1(input: &[Vec]) -> u64 { let mut sums = input .iter() .map(|el| el.iter().sum::()) .collect::>(); sums.sort(); sums.pop().unwrap() } #[aoc(day1, part2)] pub fn solve_part2(input: &[Vec]) -> u64 { let mut sums = input .iter() .map(|el| el.iter().sum::()) .collect::>(); sums.sort(); sums[sums.len() - 3..sums.len()].iter().sum::() }