use std::collections::HashSet; fn main() -> Result<(), Box> { let lines: Vec = std::io::stdin().lines().map(|x| x.unwrap()).collect(); let mut result = 0; for line in lines { let chars: Vec = line.chars().collect(); let a: HashSet = (chars[0..chars.len()/2]).iter().map(|x| *x).collect(); let b: HashSet = (chars[chars.len()/2..]).iter().map(|x| *x).collect(); let c = *a.intersection(&b).next().unwrap(); result += match c { 'a'..='z' => (c as u32) - ('a' as u32) + 1, 'A'..='Z' => (c as u32) - ('A' as u32) + 27, _ => todo!(), }; } println!("{:?}", result); Ok(()) }