diff --git a/day25.py b/day25.py new file mode 100644 index 0000000..58a9896 --- /dev/null +++ b/day25.py @@ -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 diff --git a/inputs/25 b/inputs/25 new file mode 100644 index 0000000..8e139ed --- /dev/null +++ b/inputs/25 @@ -0,0 +1,2 @@ +8335663 +8614349 diff --git a/inputs/25_test b/inputs/25_test new file mode 100644 index 0000000..9cbfc23 --- /dev/null +++ b/inputs/25_test @@ -0,0 +1,2 @@ +5764801 +17807724