def scan_area(memory:list, x_lim:int, y_lim:int) -> Union[list, int]: program = IntcodeComputer(memory) area = [['.']*x_lim for __ in range(y_lim)] affected = 0 for x, y in product(range(x_lim), range(y_lim)): out = [] program.execute(deque([x,y]), out) program.reset() if out[-1] == 1: area[y][x] = '#' affected += 1 return area, affected
def in_beam(program:IntcodeComputer, x:int, y:int) -> int: out = [] program.execute(deque([x,y]), out) program.reset() return out.pop()