Skip to content

Commit

Permalink
Update day14
Browse files Browse the repository at this point in the history
  • Loading branch information
starkindustries committed Dec 14, 2023
1 parent b2a396c commit 64a943c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions 2023/14/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ def solve(filename, part2=False):

for j, prev in enumerate(prev_spheres):
if prev == spheres2:
cycles_to_go = (cycles - j) % (i - j)
spheres2 = prev_spheres[j + cycles_to_go - 1]
# cycles_to_go
# .-- total required cycles
# | .-- # cycles already completed
# v v v-- # cycles in pattern
cycles_to_go = (cycles - (i + 1)) % (i - j)
spheres2 = prev_spheres[j + cycles_to_go]
found_pattern = True
break
if found_pattern:
Expand Down

0 comments on commit 64a943c

Please sign in to comment.