diff --git a/src/day07.rs b/src/day07.rs index 584d914..036b291 100644 --- a/src/day07.rs +++ b/src/day07.rs @@ -121,16 +121,11 @@ fn compute_dir_sizes(input: &[CliOperation]) -> Tree<(usize, usize)> { #[aoc(day7, part1)] fn solve_part1(input: &[CliOperation]) -> usize { let tree = compute_dir_sizes(input); - let mut sum = 0; - for node in tree - .traverse_post_order(tree.root_node_id().unwrap()) + tree.traverse_post_order(tree.root_node_id().unwrap()) .unwrap() - { - if node.data().1 <= 100000 { - sum += node.data().1; - } - } - sum + .map(|node| node.data().1) + .filter(|&size| size <= 100_000) + .sum() } #[aoc(day7, part2)]