2023-15: Implement part two

This commit is contained in:
Mathis 2023-12-24 12:57:29 +01:00
parent 5444a86e22
commit 672d196e2a
2 changed files with 7 additions and 8 deletions

View File

@ -11,7 +11,7 @@ pub struct DaySolution ;
impl Solution for DaySolution {
fn input_path(&self) -> &'static str {
"input/2023/day_15/input_test.txt"
"input/2023/day_15/input.txt"
}
fn part_one(&self) -> String {

View File

@ -18,8 +18,6 @@ pub fn part_two(input_lines: Vec<String>) -> String {
let parsed_seq = parse_sequence(seq);
let hash = hash_sequence(parsed_seq[0].clone());
println!("{}: {:?}", hash, parsed_seq.clone());
if parsed_seq[1] == "=" {
let mut lenses = boxes.get(&hash).unwrap().clone();
let mut found: bool = false;
@ -51,14 +49,15 @@ pub fn part_two(input_lines: Vec<String>) -> String {
}
}
println!();
for (k, v) in &boxes {
if v.len() > 0 {
println!("{}: {:?}", k, v);
let mut res = 0;
for i in 0..256 {
let lenses = boxes.get(&i).unwrap().clone();
for (j, lens) in lenses.iter().enumerate() {
res += (i + 1) * (j + 1) * lens.1;
}
}
String::from("Not implemented")
res.to_string()
}
fn hash_sequence(sequence: String) -> usize {