-use std::io::{BufRead, Lines};
+use std::io::BufRead;
use itertools::Itertools;
R: BufRead
{
let mut sum = 0;
- let mut item_count = [0i32; 52];
+ let mut item_set = [0u8; 52];
for group in reader.lines().chunks(3).into_iter() {
- item_count.fill(0);
+ item_set.fill(0);
for (i, rucksack) in group.enumerate() {
let items = rucksack.unwrap();
for b in items.as_bytes().into_iter() {
let v = letter_to_priority(*b);
- if i == 2 && item_count[v as usize - 1] == 3 {
+ if i == 2 && item_set[v as usize - 1] == 3 {
sum += v as i32;
break;
}
- item_count[v as usize - 1] |= 1 << i;
+ item_set[v as usize - 1] |= 1 << i;
}
}
}