diff options
Diffstat (limited to '19/py/d09.py')
| -rw-r--r-- | 19/py/d09.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/19/py/d09.py b/19/py/d09.py new file mode 100644 index 0000000..ada6763 --- /dev/null +++ b/19/py/d09.py @@ -0,0 +1,27 @@ +import intcode + +def do(input, code): + program = [int(x) for x in input.split(",")] + c = intcode.Computer(program) + c.input = code + output = [] + while True: + c.step() + #print(c.relative_base, c.pointer, c.memory) + if c.SIG_HALT: + break + if c.output is not None: + output.append(c.output) + c.output = None + return output + +def pt1(input): + return do(input[0], 1) + +def pt2(input): + return do(input[0], 2) + +if __name__ == "__main__": + input = open("../input/09", "r").readlines() + print(pt1(input)) + print(pt2(input)) |
