Skip to content

Instantly share code, notes, and snippets.

@rendyanthony
Last active December 28, 2020 03:41
Show Gist options
  • Save rendyanthony/2f0df37b4e41cc88fd223f60d4e7aab4 to your computer and use it in GitHub Desktop.
Save rendyanthony/2f0df37b4e41cc88fd223f60d4e7aab4 to your computer and use it in GitHub Desktop.
Advent of Code 2020 Day 25
def get_loops(*search, max_iter=10000000):
value = 1
n = 1
while search and n <= max_iter:
value = (value * 7) % 20201227
if value in search:
yield (value, n)
n += 1
## Part 1
pk_1, pk_2 = 1327981, 2822615
loops = dict(get_loops(pk_1, pk_2))
print(
pow(pk_1, loops[pk_2], 20201227),
pow(pk_2, loops[pk_1], 20201227))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment