diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-13 09:10:22 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-13 09:10:22 +0100 |
| commit | bb432b66d00deb7d4a259389fe45fba7bac202cc (patch) | |
| tree | 62d908d35b26b0c404deac0ea41dbcdb261de2fd /solutions/py/intcode.py | |
| parent | a1750786a062a792e66bf2c37a75c4c5e0f34c9a (diff) | |
| download | aoc-bb432b66d00deb7d4a259389fe45fba7bac202cc.tar.gz | |
Day 13 py
Diffstat (limited to 'solutions/py/intcode.py')
| -rw-r--r-- | solutions/py/intcode.py | 5 |
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: |
