38 lines
983 B
Rust
38 lines
983 B
Rust
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
|
|
}
|
|
|
|
fn part_2(&self, input: &str) -> Answer {
|
|
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)
|
|
}
|