From b672158dc1ccd12b5615fbfe03524e979ef4da52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 21 Dec 2019 14:06:16 +0100 Subject: Day 21 part 2 --- 19/py/21.js | 14 ++++++++++++++ 19/py/d21.py | 28 ++++++---------------------- 2 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 19/py/21.js diff --git a/19/py/21.js b/19/py/21.js new file mode 100644 index 0000000..7267d45 --- /dev/null +++ b/19/py/21.js @@ -0,0 +1,14 @@ +# part1 +or A T +and B T +and C T +not T J +and D J +# part2 +not F T +not T T +or I T +and E T +or H T +and T J +run diff --git a/19/py/d21.py b/19/py/d21.py index 3b2e123..b4ad1eb 100644 --- a/19/py/d21.py +++ b/19/py/d21.py @@ -1,14 +1,3 @@ -# program and idea for part 1: -# jump if any tile of the first three aren't ground and the fourth is ground -# J = (not A or not B or not C) and D -# (dm) <=> J = not (A and B and C) and D -# or A T -# and B T -# and C T -# not T J -# and D J -# walk - import intcode f = open("../input/21", "r").readlines() @@ -27,19 +16,14 @@ def ascii_draw(a): print("[INVALID ASCII]", c) return s +jumpscript = open("21.js", "r").readlines() +for line in jumpscript: + if line[0] != "#": + c.queue_ascii(line.strip().upper()) + print(line.strip().upper()) + while not c.SIG_HALT: c.step() - if c.SIG_INPUT: - # flush output - print(ascii_draw(output)) - output = [] - if len(output) > 0: - output = [] - while True: - s = input() - if s.upper() == "END": - break - c.queue_ascii(s.upper()) if c.SIG_OUTPUT: output.append(c.output) c.output = None -- cgit v1.2.1