Day 1, puzzle 2

This commit is contained in:
jazzpi
2022-12-13 13:11:56 +01:00
parent 84ee26264b
commit 108ef47eb5
3 changed files with 40 additions and 0 deletions

15
src/bin/d1p2.rs Normal file
View File

@ -0,0 +1,15 @@
use aoc22::day1;
use aoc22::util;
const N_ELVES: usize = 3;
fn main() {
let elves = day1::read_elves();
let max_vals = util::max_n(elves.as_slice(), N_ELVES).unwrap();
println!(
"The {} elves with the most calories are carrying {} cal",
N_ELVES,
max_vals.iter().sum::<u32>()
);
}