def state_to_counts(fish):
    """converts an array of fish to a list of counts.
    eg. [3,4,3,1,2] => [0,1,1,2,1,0,0,0,0]
    each value in the array is the number of fish which have this count.
    eg. [0,1,1,2,1,0,0,0,0] is one '1' one '2' two '3's one '4' and no other fish
    """
    result = [0] * 9
    for f in fish:
        result[f] += 1
    return result