1use crate::util::iter::*;
12use crate::util::parse::*;
13
14type Gift = [u32; 3];
15
16pub fn parse(input: &str) -> Vec<Gift> {
17 input
18 .iter_unsigned()
19 .chunk::<3>()
20 .map(|chunk| {
21 let mut gift = chunk;
22 gift.sort_unstable();
23 gift
24 })
25 .collect()
26}
27
28pub fn part1(input: &[Gift]) -> u32 {
29 input.iter().map(|[l, w, h]| 2 * (l * w + w * h + h * l) + l * w).sum()
30}
31
32pub fn part2(input: &[Gift]) -> u32 {
33 input.iter().map(|[l, w, h]| 2 * (l + w) + (l * w * h)).sum()
34}