diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-14 09:00:29 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-14 09:00:29 +0100 |
| commit | 18ee463da09b4f7fd0f5d5bf04690fdb9027bcfb (patch) | |
| tree | 4186016be62794b603d150fe9122fc9f0519014a /solutions/py/d09.py | |
| parent | af1a6b34c19c50ee36be79ab4d7cdf902f42b99e (diff) | |
| download | aoc-18ee463da09b4f7fd0f5d5bf04690fdb9027bcfb.tar.gz | |
Refactor (and faster?) intcode and day 9+13
Diffstat (limited to 'solutions/py/d09.py')
| -rw-r--r-- | solutions/py/d09.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/solutions/py/d09.py b/solutions/py/d09.py index 7495d3a..ada6763 100644 --- a/solutions/py/d09.py +++ b/solutions/py/d09.py @@ -5,9 +5,11 @@ def do(input, code): c = intcode.Computer(program) c.input = code output = [] - while c.memory[c.pointer] != 99: + 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 @@ -20,10 +22,6 @@ def pt2(input): return do(input[0], 2) if __name__ == "__main__": - import cProfile - input = open("../input/09", "r").readlines() - cProfile.run("pt1(input)") - cProfile.run("pt2(input)") print(pt1(input)) print(pt2(input)) |
