18 lines
535 B
Rust
18 lines
535 B
Rust
use aoc22::day3;
|
|
use aoc22::util;
|
|
|
|
pub fn main() {
|
|
let rucksacks = day3::parse_rucksacks(&util::parse_input());
|
|
|
|
let mut sum = 0;
|
|
for group in rucksacks.chunks_exact(3) {
|
|
// Intersection of the unions of each rucksack's compartments
|
|
let common = &(&(&group[0].0 | &group[0].1) & &(&group[1].0 | &group[1].1))
|
|
& &(&group[2].0 | &group[2].1);
|
|
assert!(common.len() == 1);
|
|
sum += day3::priority(*common.iter().next().unwrap());
|
|
}
|
|
|
|
println!("Sum of priorities is {}", sum);
|
|
}
|