Esempio n. 1
0
def run_robot(panels):
    state = (complex(0, 0), complex(0, 1))

    def update_state(state, turn):
        new_dir = state[1] * turn
        return (state[0] + new_dir, new_dir)

    robot = Intcode(task_data)

    while robot.running:
        color_underneath = panels[state[0]]

        robot.put(color_underneath)
        color_to_paint = robot.get()
        direction = robot.get()

        turn = LEFT if direction == 0 else RIGHT

        panels[state[0]] = color_to_paint
        state = update_state(state, turn)

    return panels
Esempio n. 2
0
File: 13.py Progetto: cymerrad/aoc
def read_n_triples(m: Intcode, n):
    for _ in range(n):
        yield (m.get(), m.get(), m.get())