def run_diagnostic(states, start_state, iterations): tape = Tape() next_state = start_state for i in range(iterations): next_steps = states[next_state].eval(tape.mem_value) tape.mark_pos(next_steps[0]) tape.shift(next_steps[1]) next_state = next_steps[2] return tape