Last active
December 28, 2020 03:41
-
-
Save rendyanthony/2f0df37b4e41cc88fd223f60d4e7aab4 to your computer and use it in GitHub Desktop.
Advent of Code 2020 Day 25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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