diff --git a/src/day_1.rs b/src/day_1.rs index 8da50e7..2e61ddb 100644 --- a/src/day_1.rs +++ b/src/day_1.rs @@ -24,9 +24,7 @@ pub fn part_2(input: &String) -> u64 { }).collect(); elf_calorie_counts.sort_unstable(); + elf_calorie_counts.reverse(); - let start = elf_calorie_counts.len() - 3; - let top_3 = elf_calorie_counts.drain(start..); - - top_3.sum() + elf_calorie_counts.iter().take(3).sum() }