-
Notifications
You must be signed in to change notification settings - Fork 0
/
day24.py
43 lines (36 loc) · 1022 Bytes
/
day24.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from util import Day
from aocd import submit
from itertools import product
from numba import njit
def process_input(data):
out = []
for i, instruction in enumerate(data):
if (i%18)==15:
out.append(int(instruction.split()[-1]))
return out
def test_alu(instructions):
for model_number in product(range(9, 0, -1), repeat=14):
if 0 in model_number:
continue
z = 0
for program, n in zip(instructions, model_number):
z = z * 26 + program + n
if z == 0:
return model_number
def main(day, part=1):
day.data = process_input(day.data)
if part == 1:
return test_alu(instructions=day.data)
if part == 2:
pass
if __name__ == "__main__":
day = Day(24)
day.download()
day.load(typing=str)
p1 = main(day)
print(p1)
# submit(p1, part="a", day=24, year=2021)
# day.load(typing=str)
# p2 = main(day, part=2)
# print(p2)
# submit(p2, part="b", day=24, year=2021)