use crate::prelude::*; pub fn solution() -> Solution { Solution::new(Day::new(1, 2020), part_1, part_2) .with_expected(605364, 128397680) } const TARGET: i32 = 2020; fn parse_lines(input: &str) -> Vec { input .lines() .filter_map(|line| line.parse::().ok()) .collect() } fn part_1(input: &str) -> Result { Ok( parse_lines(input) .into_iter() .tuple_combinations() .find(|(a, b)| a + b == TARGET) .map(|(a, b)| a * b) .unwrap() .to_string(), ) } fn part_2(input: &str) -> Result { Ok( parse_lines(input) .into_iter() .tuple_combinations() .find(|(a, b, c)| a + b + c == TARGET) .map(|(a, b, c)| a * b * c) .unwrap() .to_string(), ) }