This commit is contained in:
the 2020-12-25 21:40:08 +00:00
parent f544398fd8
commit 9bf1566764
1 changed files with 34 additions and 0 deletions

34
day25.py Normal file
View File

@ -0,0 +1,34 @@
card_public_key, door_public_key = 12092626, 4707356
# card_public_key, door_public_key = 5764801, 17807724
def loop_size_from(expected):
value = 1
subject_number = 7
count = 0
while value != expected:
count += 1
value = (value * subject_number) % 20201227
return count
card_loop_size = loop_size_from(card_public_key)
# door_loop_size = loop_size_from(door_public_key)
print(card_loop_size)
# print(door_loop_size)
def encryption(public_key, loop_size):
value = 1
subject_number = public_key
for _ in range(loop_size):
value = (value * subject_number) % 20201227
return value
# e1 = encryption(card_public_key, door_loop_size)
e2 = encryption(door_public_key, card_loop_size)
# print(e1)
print(e2)