"""PA1 Chutes and Ladders.

A track is a list where track[square] is the square that square sends you to.
Most squares send you to themselves; a ladder sends you up, and a chute sends
you down. Square 0 is the start, and the last square is the finish.

Name: YOUR NAME
Date: THE DATE
"""


def make_track(size, starts, ends):
    """Build a track with ladders and chutes.

    Args:
        size (int): The number of the finish square, such as 100.
        starts (list): The squares where a ladder or chute begins.
        ends (list): Where each one ends; ends[i] goes with starts[i].

    Returns:
        list: A new list of size + 1 ints, where item s is the square that
        square s sends you to. Ex: make_track(5, [1, 4], [3, 2]) returns
        [0, 3, 2, 3, 2, 5], with a ladder from 1 to 3 and a chute from 4 to 2.
        The starts and ends lists are not changed.
    """
    pass


def move(track, position, roll):
    """Take one turn.

    A player on the finish square stays there. Otherwise the player moves
    forward roll squares. A roll that would go past the finish bounces back
    from it by the squares left over: on a track that finishes at 10, a player
    on 8 who rolls 4 counts 9, 10, then back to 9 and 8. Then the player
    follows the square they land on, up a ladder or down a chute.

    Args:
        track (list): The track, as made by make_track.
        position (int): The square the player is on.
        roll (int): The number rolled, from 1 to 6.

    Returns:
        int: The square the player ends the turn on.
    """
    pass


def play(track, rolls):
    """Play a one-player game from a list of rolls.

    The player starts on square 0 and takes one turn per roll, in order,
    using every roll even after reaching the finish.

    Args:
        track (list): The track, as made by make_track.
        rolls (list): The numbers rolled, one per turn.

    Returns:
        tuple: A new list of the square the player is on after each turn, and
        the turn number (counting from 1) on which the player first reached
        the finish, or -1 if they never did. Ex: on make_track(5, [1, 4],
        [3, 2]), the rolls [1, 1, 4] return ([3, 2, 2], -1), since the 4
        bounces back to square 4 and its chute, and the rolls [1, 2, 3]
        return ([3, 5, 5], 2). The rolls list is not changed.
    """
    pass


if __name__ == "__main__":
    # Do not edit the main block. It prints a game once play() works.
    track = make_track(30, [3, 8, 17, 27], [12, 22, 5, 9])
    rolls = [3, 5, 6, 4, 2, 6, 5, 3, 6, 6, 1, 4]
    positions, won = play(track, rolls)
    for turn in range(len(rolls)):
        print(f"Turn {turn + 1}: rolled {rolls[turn]}, now on square {positions[turn]}")
    if won == -1:
        print(f"Not finished after {len(rolls)} turns")
    else:
        print(f"Reached square 30 on turn {won}")
