|
|
|
|
@ -14,6 +14,10 @@ class OpcodeComputer(): |
|
|
|
|
https://adventofcode.com/2019/day/5 |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
memory = [] |
|
|
|
|
|
|
|
|
|
def __init__(self, mem: List[int]) -> None: |
|
|
|
|
self.memory = mem |
|
|
|
|
|
|
|
|
|
def parse_param(self, pc: int, mem: List[int]) \ |
|
|
|
|
-> Tuple[int, int, int, int]: |
|
|
|
|
@ -38,7 +42,7 @@ class OpcodeComputer(): |
|
|
|
|
pass |
|
|
|
|
return (int(i[-2:]), a, b, c) |
|
|
|
|
|
|
|
|
|
def process_op(self, mem: List[int]) -> int: |
|
|
|
|
def process_op(self) -> int: |
|
|
|
|
"""Run program code |
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
|
@ -48,7 +52,9 @@ class OpcodeComputer(): |
|
|
|
|
int: Content in memory at position 0 |
|
|
|
|
""" |
|
|
|
|
pc: int = 0 |
|
|
|
|
mem = list(self.memory) |
|
|
|
|
cmd: int = mem[pc] |
|
|
|
|
|
|
|
|
|
while cmd != 99: |
|
|
|
|
cmd, a, b, c = self.parse_param(pc, mem) |
|
|
|
|
if cmd == 1: |
|
|
|
|
|