Almost done haha
This commit is contained in:
parent
10b594e479
commit
f4d2d3bf24
4 changed files with 327 additions and 4 deletions
19
src/prob3/mod.rs
Normal file
19
src/prob3/mod.rs
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue