Day 3, puzzle 1

This commit is contained in:
jazzpi
2022-12-13 14:37:15 +01:00
parent 7dde03f46f
commit adb8cfd91a
3 changed files with 41 additions and 0 deletions

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

@ -0,0 +1,15 @@
use aoc22::day3;
use aoc22::util;
pub fn main() {
let rucksacks = day3::parse_rucksacks(&util::parse_input());
let mut sum = 0;
for (first, second) in rucksacks {
let common: Vec<_> = first.intersection(&second).collect();
assert!(common.len() == 1);
sum += day3::priority(**common.first().unwrap());
}
println!("Sum of priorities is {}", sum);
}