static INPUT: &str = include_str!("input.txt"); fn main() { let valueified = INPUT .split('\n') .filter(|s| !s.is_empty()) .map(|line| { let mut nums = line .split('x') .map(str::parse::) .map(Result::unwrap); (nums.next().unwrap(), nums.next().unwrap(), nums.next().unwrap()) }); let final_area: u32 = valueified.clone() .map(|(w, l, h)| { let sides = [w*h, l*w, h*l]; sides.into_iter().min().unwrap() + sides.into_iter().sum::() * 2 }) .sum(); println!("Final area: {final_area}"); let ribbon_length: u32 = valueified .map(|(w, l, h)| { let mut nums = [w, l, h]; nums.sort(); (nums[0] + nums[1]) * 2 + (w * l * h) }) .sum(); println!("Ribbon length: {ribbon_length}"); }