This commit is contained in:
Ethanell 2019-12-02 09:33:27 +01:00
parent 0c83aadcf9
commit 61ae887bbc
2 changed files with 25 additions and 0 deletions

24
2019/day 2/P2/computer.py Normal file
View file

@ -0,0 +1,24 @@
codes = open("input.txt").read().split(",")
noun = -1
verb = -1
while noun <= 99:
noun+=1
verb=-1
while verb <= 99:
verb+=1
codes = open("input.txt").read().split(",")
codes = [int(i) for i in codes]
codes[1] = noun
codes[2] = verb
i=0
while codes[i+3] < len(codes) and codes[i] != 99:
if codes[i] == 1:
codes[codes[i+3]] = codes[codes[i+1]] + codes[codes[i+2]]
elif codes[i] == 2:
codes[codes[i+3]] = codes[codes[i+1]] * codes[codes[i+2]]
i+=4
if codes[0] == 19690720:
print(f"{100*noun+verb}")
exit()

1
2019/day 2/P2/input.txt Normal file
View file

@ -0,0 +1 @@
1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,13,1,19,1,19,10,23,2,10,23,27,1,27,6,31,1,13,31,35,1,13,35,39,1,39,10,43,2,43,13,47,1,47,9,51,2,51,13,55,1,5,55,59,2,59,9,63,1,13,63,67,2,13,67,71,1,71,5,75,2,75,13,79,1,79,6,83,1,83,5,87,2,87,6,91,1,5,91,95,1,95,13,99,2,99,6,103,1,5,103,107,1,107,9,111,2,6,111,115,1,5,115,119,1,119,2,123,1,6,123,0,99,2,14,0,0