File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 26
26
| [ 22] ( https://adventofcode.com/2020/day/22 ) | Crab Combat| [ py] ( /day22/main.py ) |
27
27
| [ 23] ( https://adventofcode.com/2020/day/23 ) | Crab Cups| [ py] ( /day23/main.py ) |
28
28
| [ 24] ( https://adventofcode.com/2020/day/24 ) | Lobby Layout| [ py] ( /day24/main.py ) |
29
- | [ 25] ( https://adventofcode.com/2020/day/25 ) | - | - |
29
+ | [ 25] ( https://adventofcode.com/2020/day/25 ) | Combo Breaker | [ py ] ( /day25/main.py ) |
Original file line number Diff line number Diff line change
1
+ with open ("input.txt" ) as f :
2
+ public_key_card , public_key_door = [int (x .strip ()) for x in f ]
3
+
4
+ def calc_loop_size (public_key ):
5
+ subject_number = 7
6
+ n = 1
7
+ i = 0
8
+ while True :
9
+ n = (n * subject_number ) % 20201227
10
+ if n == public_key :
11
+ return i + 1
12
+ i += 1
13
+
14
+ def calc_encryption_key (subject_number , loop_size ):
15
+ n = 1
16
+ for i in range (loop_size ):
17
+ n = (n * subject_number ) % 20201227
18
+ return n
19
+
20
+ loop_size = calc_loop_size (public_key_card )
21
+ enc_key = calc_encryption_key (public_key_door , loop_size )
22
+ print (enc_key )
You can’t perform that action at this time.
0 commit comments