34 lines
800 B
Python
34 lines
800 B
Python
import aoclib
|
|
|
|
DAY = 25
|
|
TEST_SOLUTION_PART1 = 14897079
|
|
TEST_SOLUTION_PART2 = 0
|
|
|
|
|
|
def transform(key, subject_number, loop_size=1):
|
|
for _ in range(loop_size):
|
|
key = key * subject_number % 20201227
|
|
|
|
return key
|
|
|
|
|
|
def part1(test_mode=False):
|
|
my_input = aoclib.getInputAsArray(day=DAY, return_type=int, test=test_mode)
|
|
|
|
loop_card = 1
|
|
public_key_card = 1
|
|
while pow(7, loop_card, 20201227) != my_input[0]:
|
|
loop_card += 1
|
|
public_key_card = transform(public_key_card, 7)
|
|
|
|
public_key_door = my_input[1]
|
|
|
|
# as we start with a key of 1, it's just a matter of
|
|
# multiplying public_key_door with itself loop_card times ....
|
|
return pow(public_key_door, loop_card, 20201227)
|
|
|
|
|
|
def part2(test_mode=False):
|
|
# there is no part2 for day 25
|
|
return 0
|