This commit is contained in:
Spectre 2024-12-23 19:11:47 +01:00
parent 290d9a5cb0
commit d87aad0252
4 changed files with 131 additions and 2 deletions

View file

@ -1,9 +1,16 @@
use std::collections::{HashMap, HashSet};
use shared::{Solution, Answer};
pub struct Day05;
impl Solution for Day05 {
fn part_1(&self, input: &str) -> Answer {
let (p1, p2) = parse(input);
// let res = p2.iter()
// .filter(|&update| )
Answer::Unimplemented
}
@ -11,3 +18,21 @@ impl Solution for Day05 {
Answer::Unimplemented
}
}
fn parse(input: &str) -> (HashMap<u32, HashSet<u32>>, Vec<Vec<u32>>) {
let (first, second) = input.split_once("\n\n").unwrap();
let mut out1: HashMap::<u32, HashSet<u32>> = HashMap::new();
for (a, b) in first
.lines()
.map(|s| s.split_once("|")
.unwrap())
.map(|(a, b)| (a.parse::<u32>().unwrap(), b.parse::<u32>().unwrap())) {
out1.entry(a).or_default().insert(b);
};
let out2: Vec<Vec<u32>> = second.lines().map(|line| line.split(",").map(|x| x.parse::<u32>().unwrap()).collect()).collect();
(out1, out2)
}