day25 bruteforce
This commit is contained in:
parent
7b6c3bfa2a
commit
a9452f5231
36
day25.py
Normal file
36
day25.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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 = 0
|
||||||
|
public_key_card = 1
|
||||||
|
while public_key_card != my_input[0]:
|
||||||
|
loop_card += 1
|
||||||
|
public_key_card = transform(public_key_card, 7)
|
||||||
|
|
||||||
|
loop_door = 0
|
||||||
|
public_key_door = 1
|
||||||
|
while public_key_door != my_input[1]:
|
||||||
|
loop_door += 1
|
||||||
|
public_key_door = transform(public_key_door, 7)
|
||||||
|
|
||||||
|
print("Loops: %d (card), %d (door)" % (loop_card, loop_door))
|
||||||
|
|
||||||
|
return transform(1, public_key_door, loop_card)
|
||||||
|
|
||||||
|
|
||||||
|
def part2(test_mode=False):
|
||||||
|
# there is no part2 for day 25
|
||||||
|
return 0
|
||||||
2
inputs/25_test
Normal file
2
inputs/25_test
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
5764801
|
||||||
|
17807724
|
||||||
Loading…
Reference in New Issue
Block a user