Day 19 2018 wip
This commit is contained in:
parent
9f616a5b81
commit
d2417a9377
41
2018/d19.py
Normal file
41
2018/d19.py
Normal file
@ -0,0 +1,41 @@
|
||||
from lib import get_data, str_to_ints
|
||||
import d16
|
||||
|
||||
|
||||
def part_1(data):
|
||||
ip = None
|
||||
regs = [0 for _ in range(6)]
|
||||
|
||||
regs[0] = 1 # part 2
|
||||
|
||||
insts = []
|
||||
for line in data.splitlines():
|
||||
if line.startswith("#"):
|
||||
ip, = str_to_ints(line)
|
||||
else:
|
||||
fs = line.split()
|
||||
vals = str_to_ints(line)
|
||||
insts.append([fs[0]] + vals)
|
||||
|
||||
assert ip is not None
|
||||
while regs[ip] < len(insts):
|
||||
inst = insts[regs[ip]]
|
||||
f = getattr(d16, inst[0])
|
||||
# if inst[1:] == [3, 1, 3]:
|
||||
# regs[3] = regs[1]
|
||||
# regs[4] = regs[1]
|
||||
f(regs, *inst[1:])
|
||||
regs[ip] += 1
|
||||
print(regs, regs[-1] + 1)
|
||||
print(regs[0])
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
data = get_data(__file__)
|
||||
part_1(data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user