From 673e8184ed8e65c99033826ff6aa1fc606243b47 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Fri, 15 Dec 2023 09:03:06 +0100 Subject: [PATCH] Zero init > 1 init --- 2023/src/day15.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2023/src/day15.rs b/2023/src/day15.rs index c3bc1fb..4915159 100644 --- a/2023/src/day15.rs +++ b/2023/src/day15.rs @@ -73,15 +73,15 @@ pub fn part2(input: &[u8]) -> anyhow::Result { } } - let mut box_slot = [1; 256]; + let mut box_slot = [0; 256]; let mut total = 0; for (&identifier, &focal_len) in &state { let index = hash(identifier); let box_no = u32::from(index) + 1; let slot_no = &mut box_slot[index as usize]; - total += box_no * *slot_no * focal_len; *slot_no += 1; + total += box_no * *slot_no * focal_len; } Ok(total.to_string())