def connect_reachable_exit(entrance, caves, doors):
    cave = extract_reachable_exit(caves)
    exit = cave[(- 1)]
    cave = cave[:(- 1)]
    connect_exit(world, exit, entrance, player)
    connect_entrance(world, doors.pop(), exit, player)
    caves.append(cave)
def connect_reachable_exit(entrance, caves, doors):
    cave = extract_reachable_exit(caves)
    exit = cave[(- 1)]
    cave = cave[:(- 1)]
    connect_exit(world, exit, entrance, player)
    connect_entrance(world, doors.pop(), exit, player)
    caves.append(cave)