use std::collections::HashSet; pub fn solve_part1(file_path: &str) -> i32 { let binding = std::fs::read_to_string(file_path).expect("Please provide a text file as an argument."); binding .lines() .collect::>() .iter() .map(|item: &&str| { let (first, last) = item.split_at(item.len() / 2); let second = last.chars().collect::>(); let intersection = first.chars().collect::>(); let character = *intersection.intersection(&second).next().unwrap_or(&(0 as char)) as i32; if character >= ('a' as i32) { character - 96 } else { character - 38 } }) .collect::>() .iter() .sum::() }