1
0
Fork 0

Almost done haha

This commit is contained in:
Pcornat 2022-12-05 20:23:57 +01:00
parent 10b594e479
commit f4d2d3bf24
Signed by: Pcornat
GPG key ID: 2F3932FF46D9ECA0
4 changed files with 327 additions and 4 deletions

19
src/prob3/mod.rs Normal file
View file

@ -0,0 +1,19 @@
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
}