intcode: make execute current not protected

This commit is contained in:
2021-07-03 17:59:43 +02:00
parent ca43475a44
commit 05e2a4f3a7
2 changed files with 3 additions and 3 deletions

View File

@@ -46,7 +46,7 @@ def part2(data: TextIO) -> int:
for computer in computers: for computer in computers:
try: try:
computer._execute_current() computer.execute_current()
is_idle = False is_idle = False
except IndexError: except IndexError:
computer.send_input(-1) computer.send_input(-1)

View File

@@ -70,7 +70,7 @@ class Computer:
def run(self) -> None: def run(self) -> None:
""" Run until failure """ """ Run until failure """
while self._execute_current(): while self.execute_current():
pass pass
def get_output(self) -> int: def get_output(self) -> int:
@@ -79,7 +79,7 @@ class Computer:
def send_input(self, data: int): def send_input(self, data: int):
self.input.append(data) self.input.append(data)
def _execute_current(self) -> bool: def execute_current(self) -> bool:
""" """
Execute a single instruction Execute a single instruction
:return: True if the program should continue :return: True if the program should continue