use std::collections::HashSet; fn main() { let rucksacks: Vec<(&str, &str)> = include_str!("../../input") .lines() .map(|line| line.split_at(line.len() / 2)) .collect(); let mut sum = 0; for (f, s) in rucksacks { let first: HashSet = HashSet::from_iter(f.chars()); let second: HashSet = HashSet::from_iter(s.chars()); for x in first.intersection(&second) { if x.is_lowercase() { sum += *x as i16 - 96; } else { sum += *x as i16 - 38; } } } println!("{}", sum); }