def fish(fs):
    """
    Transform a list of fish represented by their time-to-spawn state into a list of the
    number of fish in each state indexed by their time-to-spawn.

    Under this strategy, the example input [3, 4, 3, 1, 2] would be transformed into
    [0, 1, 1, 2, 1, 0, 0, 0, 0].
    """
    fis = [0] * 9
    for f in fs:
        fis[f] += 1
    return fis