From 0caad8b5b048c0c96b83d75b7d95f77262cb79b6 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Thu, 14 Dec 2023 03:49:16 -0600 Subject: [PATCH] push --- src/bin/day14.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/day14.rs b/src/bin/day14.rs index d209164..3a735e1 100644 --- a/src/bin/day14.rs +++ b/src/bin/day14.rs @@ -175,7 +175,11 @@ fn part2(input: String) -> Result { scores.push(dish.calculate_north_load()); if let Some(repeated_index) = seen.get(&dish) { // Figure out final score based on sliding window of known scores within the - // repeated pattern + // repeated pattern: + // + // (cycles - repeated index) gives us the remaining times we need to run through. We + // then get the remainder of that divided by the difference of the current index minus + // all seen (total repeating count). answer = scores [repeated_index - 1 + (cycles - repeated_index) % (seen.len() - repeated_index)]; break;