aoc/2020/25/25.py

22 lines
359 B
Python
Raw Normal View History

pubkey1 = 3418282
pubkey2 = 8719412
subject = 7
mod = 20201227
loop1 = 0
value1 = 1
while value1 != pubkey1:
value1 = (value1 * subject) % mod
loop1 += 1
loop2 = 0
value2 = 1
while value2 != pubkey2:
value2 = (value2 * subject) % mod
loop2 += 1
enckey1 = pow(pubkey2,loop1,mod)
enckey2 = pow(pubkey1,loop2,mod)
assert enckey1 == enckey2
print(enckey1)