use std::collections::HashSet; pub fn parse_rucksacks(input: &String) -> Vec<(HashSet, HashSet)> { let lines = input.lines(); let mut rucksacks = Vec::new(); for line in lines { let length = line.len(); assert!(length % 2 == 0); let (first, second) = line.split_at(length / 2); rucksacks.push((first.chars().collect(), second.chars().collect())); } rucksacks } pub fn priority(c: char) -> u32 { assert!(c.is_ascii_alphabetic()); let ord = c as u32; if c.is_ascii_lowercase() { 1 + ord - 'a' as u32 } else { 27 + ord - 'A' as u32 } }