From 6e2250450329953567a6aa552d1b6990ee0188cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 21 Dec 2019 07:45:12 +0100 Subject: Day 21 py --- 19/py/intcode.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to '19/py/intcode.py') 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: -- cgit v1.2.1