summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2019-12-21 14:06:16 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2019-12-21 20:29:34 +0100
commitb672158dc1ccd12b5615fbfe03524e979ef4da52 (patch)
tree8200ee73880df649a5cc0dda163e6be0f0e77348
parent8a6142b323462587e2feead3ba56efef280d0654 (diff)
downloadaoc-b672158dc1ccd12b5615fbfe03524e979ef4da52.tar.gz
Day 21 part 2
-rw-r--r--19/py/21.js14
-rw-r--r--19/py/d21.py28
2 files changed, 20 insertions, 22 deletions
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