1
0
Fork 0
AdvenOfCode2022/src/prob3/mod.rs

20 lines
631 B
Rust

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.");
let content = binding
.lines()
.collect::<Vec<&str>>()
.iter()
.map(|item: &&str| {
let (first, last) = item.split_at(item.len() / 2);
let second = last.chars().collect::<HashSet<char>>();
let intersection = first.chars().collect::<HashSet<char>>();
*intersection.intersection(&second).next().unwrap()
})
.collect::<Vec<char>>();
0
}