Day 2 P1
This commit is contained in:
parent
b636b2ba14
commit
0c83aadcf9
2 changed files with 15 additions and 0 deletions
14
2019/day 2/P1/computer.py
Normal file
14
2019/day 2/P1/computer.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
codes = open("input.txt").read().split(",")
|
||||
codes = [int(i) for i in codes]
|
||||
|
||||
codes[1] = 12
|
||||
codes[2] = 2
|
||||
|
||||
i=0
|
||||
while i < 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
|
||||
print(codes[0])
|
1
2019/day 2/P1/input.txt
Normal file
1
2019/day 2/P1/input.txt
Normal 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
|
Loading…
Reference in a new issue