diff --git a/src/year_2023/day_15_lens_library/mod.rs b/src/year_2023/day_15_lens_library/mod.rs index 51267c3..ac1f458 100644 --- a/src/year_2023/day_15_lens_library/mod.rs +++ b/src/year_2023/day_15_lens_library/mod.rs @@ -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 { diff --git a/src/year_2023/day_15_lens_library/part_two.rs b/src/year_2023/day_15_lens_library/part_two.rs index 7a90ce7..2c3cd04 100644 --- a/src/year_2023/day_15_lens_library/part_two.rs +++ b/src/year_2023/day_15_lens_library/part_two.rs @@ -18,8 +18,6 @@ pub fn part_two(input_lines: Vec) -> 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 { } } - 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 {