nicer with reverse

This commit is contained in:
Max Bradbury 2022-12-02 00:20:08 +00:00
parent 3704179238
commit 1d58f1e24c
1 changed files with 2 additions and 4 deletions

View File

@ -24,9 +24,7 @@ pub fn part_2(input: &String) -> u64 {
}).collect(); }).collect();
elf_calorie_counts.sort_unstable(); elf_calorie_counts.sort_unstable();
elf_calorie_counts.reverse();
let start = elf_calorie_counts.len() - 3; elf_calorie_counts.iter().take(3).sum()
let top_3 = elf_calorie_counts.drain(start..);
top_3.sum()
} }