summaryrefslogtreecommitdiffstats
path: root/solutions/py/intcode.py
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2019-12-13 09:10:22 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2019-12-13 09:10:22 +0100
commitbb432b66d00deb7d4a259389fe45fba7bac202cc (patch)
tree62d908d35b26b0c404deac0ea41dbcdb261de2fd /solutions/py/intcode.py
parenta1750786a062a792e66bf2c37a75c4c5e0f34c9a (diff)
downloadaoc-bb432b66d00deb7d4a259389fe45fba7bac202cc.tar.gz
Day 13 py
Diffstat (limited to 'solutions/py/intcode.py')
-rw-r--r--solutions/py/intcode.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/solutions/py/intcode.py b/solutions/py/intcode.py
index aee72ee..972250e 100644
--- a/solutions/py/intcode.py
+++ b/solutions/py/intcode.py
@@ -23,6 +23,7 @@ class Computer(object):
self.input = None
self.output = None
+ self.wants_input = False
def parse_op(self, op):
#TODO
@@ -70,7 +71,11 @@ class Computer(object):
self.get_param(inst, 1) * self.get_param(inst, 2))
self.pointer += 4
elif inst[0] == IN:
+ if self.input is None:
+ self.wants_input = True
+ return
self.write_param(inst, 1, self.input)
+ self.wants_input = False
self.input = None
self.pointer += 2
elif inst[0] == OUT: