-
Notifications
You must be signed in to change notification settings - Fork 0
/
day-2.1.py
25 lines (21 loc) · 853 Bytes
/
day-2.1.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
intcode = [1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,10,19,1,19,5,23,2,23,6,27,1,27,5,31,2,6,31,35,1,5,35,39,2,39,9,43,1,43,5,47,1,10,47,51,1,51,6,55,1,55,10,59,1,59,6,63,2,13,63,67,1,9,67,71,2,6,71,75,1,5,75,79,1,9,79,83,2,6,83,87,1,5,87,91,2,6,91,95,2,95,9,99,1,99,6,103,1,103,13,107,2,13,107,111,2,111,10,115,1,115,6,119,1,6,119,123,2,6,123,127,1,127,5,131,2,131,6,135,1,135,2,139,1,139,9,0,99,2,14,0,0]
intcode[1] = 12
intcode[2] = 2
i = 0
while i < len(intcode):
if intcode[i] == 99:
break
if intcode[i] == 1:
a = intcode[i+1]
b = intcode[i+2]
c = intcode[i+3]
intcode[c] = intcode[a] + intcode[b]
i += 3
elif intcode[i] == 2:
a = intcode[i+1]
b = intcode[i+2]
c = intcode[i+3]
intcode[c] = intcode[a] * intcode[b]
i += 3
i += 1
print(intcode[0])