-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.py
41 lines (28 loc) · 746 Bytes
/
2.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
import time
day = '2'
inFile = open('inputs/{}.in'.format(day), "r")
start_time = time.time()
board = []
def opcode(item):
if(item[0] == 1):
board[item[3]] = board[item[1]] + board[item[2]]
if(item[0] == 2):
board[item[3]] = board[item[1]] * board[item[2]]
if(item[0] == 99):
print(str(board[0]))
print('Execution time: {} ms'.format(round((time.time() - start_time)*1000, 1)))
exit()
def intcode():
j = 0
while(True):
line = []
for i in range(j, j+4):
line.append(board[i])
opcode(line)
j += 4
for line in inFile:
board = line.split(',')
board[1] = 12
board[2] = 2
board = map(int, board)
intcode()