diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-21 07:45:12 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-21 07:45:12 +0100 |
| commit | 6e2250450329953567a6aa552d1b6990ee0188cb (patch) | |
| tree | 7682ed57639b9e4116958d286db524e37daa969f /19/py/intcode.py | |
| parent | 756cbfd3f6b28db2ac636f5dffeee49f05f51f61 (diff) | |
| download | aoc-6e2250450329953567a6aa552d1b6990ee0188cb.tar.gz | |
Day 21 py
Diffstat (limited to '19/py/intcode.py')
| -rw-r--r-- | 19/py/intcode.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/19/py/intcode.py b/19/py/intcode.py index 123f4f3..8afa12f 100644 --- a/19/py/intcode.py +++ b/19/py/intcode.py @@ -13,10 +13,12 @@ BAS = 9 HAL = 99 class Computer(object): - def __init__(self, program): + def __init__(self, program, ascii=False): self.program = program self.memory_size = len(self.program) self.instruction_cache = {} + if ascii: + self.SIG_ASCII = True self.reset() @@ -32,7 +34,6 @@ class Computer(object): self.output = None self.SIG_INPUT = False - self.SIG_ASCII = False self.SIG_OUTPUT = False self.SIG_HALT = False @@ -43,11 +44,6 @@ class Computer(object): ops = str(op).zfill(param_amount[code]+2) self.instruction_cache[op] = [code] + [int(x) for x in ops[:-2][::-1]] return self.instruction_cache[op] - #return [code] + [(op // 10**(i+2)) % 10**(i+1) for i in range(param_amount[code])] - - def clear_flags(self): - self.input = None - self.output = None def write(self, addr, val): if addr >= self.memory_size: |
