-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday19.py
More file actions
44 lines (39 loc) · 1.19 KB
/
day19.py
File metadata and controls
44 lines (39 loc) · 1.19 KB
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
from opcode_computer import opcode_computer
import numpy as np
with open('/Users/relyea/data/input.txt') as input_file:
inpstring = input_file.readlines()
inpstring = inpstring[0].strip()
amplist = inpstring.split(',')
amplist = [int(a) for a in amplist]
bigamplist = amplist + [0]*1000
amplist_orig = copy(bigamplist)
N = 10000
thelist = []
thegrid = np.zeros((N,N))
square_not_found = True
ii = 4
jj = 0
prior_jj = 0
while square_not_found:
jj = prior_jj
beam_not_found = True
while beam_not_found:
op = opcode_computer(list(copy(list(amplist_orig))))
op.input([ii,jj])
beam = [aa for aa in op.run()][0]
if beam != 1:
jj += 1
else:
print(ii,jj,prior_jj)
prior_jj = jj
beam_not_found = False
if ii >= 99:
opposite_ii = ii - 99
opposite_jj = jj + 99
op = opcode_computer(list(copy(list(amplist_orig))))
op.input([opposite_ii,opposite_jj])
beam = [aa for aa in op.run()][0]
if beam == 1:
print(opposite_ii, opposite_jj)
square_not_found = False
ii += 1