def emergency_hull_painting_robot(start_colour=0):
    # to record the postions that have been painted
    positions_painted = set()
    # to record the current colour of each squart
    grid = {}
    # starting direction
    direction = "^"
    pos = (0, 0)

    # 0 = black
    # 1 = white

    grid[(0, 0)] = start_colour

    ic = intcode.computer(intcode.get_program("11.input.txt"))

    while not ic.is_stopped():
        colour = 0  # default colour for a panel
        if pos in grid:  # lookup colour for panel if we have previously painted it
            colour = grid[pos]

        ic.add_input(colour)

        colour = ic.run()
        if colour == None:
            continue

        turn = ic.run()
        if turn == None:
            continue

        positions_painted.add(pos)
        grid[pos] = colour

        direction = change_direction(direction, turn)
        pos = move_position(pos, direction)

    return len(positions_painted), grid
        new_pos = get_position(position, direction)

        if resp == 0:
            grid[new_pos] = 1
        elif resp == 1:
            grid[new_pos] = 2
            position = new_pos
            history.append(position)
        else:
            position = new_pos
            grid[new_pos] = 3
            render_grid()
            print("found tank at", position, "after", loops)
            return position


if __name__ == '__main__':
    prog = intcode.get_program("15.input.txt")
    random.seed(0)

    tank = find_tank(prog, get_input_strategy1)

    print("************")

    for i in range(2):
        position = start
        loops = 0
        tank = find_tank(prog, get_input_strategy2)

    print("Part 1")
            calc_max_truster_signal_feedback_loop([
                3, 26, 1001, 26, -4, 26, 3, 27, 1002, 27, 2, 27, 1, 27, 26, 27,
                4, 27, 1001, 28, -1, 28, 1005, 28, 6, 99, 0, 0, 5
            ], [9, 8, 7, 6, 5]), 139629729)

        self.assertEqual(
            calc_max_truster_signal_feedback_loop([
                3, 52, 1001, 52, -5, 52, 3, 53, 1, 52, 56, 54, 1007, 54, 5, 55,
                1005, 55, 26, 1001, 54, -5, 54, 1105, 1, 12, 1, 53, 54, 53,
                1008, 54, 0, 55, 1001, 55, 1, 55, 2, 53, 55, 53, 4, 53, 1001,
                56, -1, 56, 1005, 56, 6, 99, 0, 0, 0, 0, 10
            ], [9, 7, 8, 5, 6]), 18216)


if __name__ == '__main__':
    program = intcode.get_program('7.input.txt')

    # calculate all permutations of this list
    perms = list(itertools.permutations([0, 1, 2, 3, 4]))
    maxThrust = 0
    for x in perms:
        thrust = calc_max_truster_signal(program, x)
        if thrust > maxThrust:
            maxThrust = thrust

    print("part 1 max thrust", maxThrust)

    # calculate all permutations of this list
    perms = list(itertools.permutations([5, 6, 7, 8, 9]))
    maxThrust = 0
    for x in perms: