2019 day 21
This commit is contained in:
parent
25bd810886
commit
2eba36a29a
57
2019/d21.py
Normal file
57
2019/d21.py
Normal file
@ -0,0 +1,57 @@
|
||||
from lib import get_data, str_to_ints
|
||||
from d9 import Amp
|
||||
|
||||
data = get_data(__file__)
|
||||
xs = str_to_ints(data)
|
||||
|
||||
script = """NOT A J
|
||||
AND A J
|
||||
NOT C T
|
||||
AND D T
|
||||
OR T J
|
||||
NOT A T
|
||||
OR T J
|
||||
"""
|
||||
|
||||
a = Amp(xs)
|
||||
while not a.done:
|
||||
a.go()
|
||||
if a.input_required:
|
||||
for c in script:
|
||||
a.feed(ord(c))
|
||||
for c in "WALK\n":
|
||||
a.feed(ord(c))
|
||||
|
||||
while a.outputs:
|
||||
c = a.pop()
|
||||
try:
|
||||
chr(c)
|
||||
# print(chr(c), end="")
|
||||
except ValueError:
|
||||
print(c)
|
||||
|
||||
script = """NOT C J
|
||||
AND H J
|
||||
NOT A T
|
||||
OR T J
|
||||
NOT B T
|
||||
OR T J
|
||||
AND D J
|
||||
"""
|
||||
|
||||
a = Amp(xs)
|
||||
while not a.done:
|
||||
a.go()
|
||||
if a.input_required:
|
||||
for c in script:
|
||||
a.feed(ord(c))
|
||||
for c in "RUN\n":
|
||||
a.feed(ord(c))
|
||||
|
||||
while a.outputs:
|
||||
c = a.pop()
|
||||
try:
|
||||
chr(c)
|
||||
# print(chr(c), end="")
|
||||
except ValueError:
|
||||
print(c)
|
@ -134,7 +134,8 @@ Solutions and utility script for Advent of Code challenges in Python.
|
||||
- Day 18: days (Slow and slow algorithm.)
|
||||
- Day 19: 40:00 (Way too slow! Oversight error. Come on.)
|
||||
- Day 20: days (Not actually that hard but I struggled for no reason.)
|
||||
- Day 21:
|
||||
- Day 21: days (But it was super fun!)
|
||||
- Day 22:
|
||||
|
||||
## AoC 2020
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user