diff options
Diffstat (limited to '2020/aoc2020-d25.py')
| -rw-r--r-- | 2020/aoc2020-d25.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/2020/aoc2020-d25.py b/2020/aoc2020-d25.py new file mode 100644 index 0000000..28d1afe --- /dev/null +++ b/2020/aoc2020-d25.py @@ -0,0 +1,29 @@ +#advent of code 2020 +#day 25 +#I made a mistake by thinking that subject number is an unknow +#while in reality it actually is =7 as in puzzle description + +def FindNumbers(pubkey): + S = 7; + L = 0; + v = 1; + while True: + L += 1; + v *= S; + v = v%20201227; + if v == pubkey: + return L; #gives loop number + +PuzzleInput = open("25.in","r").read().split("\n"); +cardkey = int(PuzzleInput[0]); +doorkey = int(PuzzleInput[1]); +#encryption key is the same +#whether we use loop of card + subject of door +#or loop of door + subject of card +encryption = 1; +for l in range(FindNumbers(cardkey)): + encryption *= doorkey; + encryption = encryption%20201227; + +part1 = encryption; +print("part 1 =", part1); |
