-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2B.py
50 lines (35 loc) · 978 Bytes
/
2B.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
44
45
46
47
48
49
50
import time
day = "2B"
inFile = open('inputs/{}.in'.format(day), "r")
start_time = time.time()
start = []
board = []
desired = 19690720
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]]
def intcode(a,b):
j = 0
board[1] = a
board[2] = b
while(j < len(board)-4):
line = []
for i in range(j, j+4):
line.append(board[i])
opcode(line)
j += 4
if(board[0] == desired):
print('{}{}'.format(board[1], board[2]))
print('Execution time: {} ms'.format(round((time.time() - start_time)*1000, 1)))
exit()
for line in inFile:
start = line.split(',')
permutations = [[k,l] for k in range(0,100)
for l in range(0,100)]
for perm in permutations:
board = map(int, start)
board[1] = 12
board[2] = 2
intcode(perm[0],perm[1])