mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
intcode: make execute current not protected
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user