def _generate(item_counts):
    """
    item_counts is a list of counts of "types" of items. E.g., [3, 1, 0, 2] represents
    a list containing [1, 1, 1, 2, 4, 4] (3 types of items/distinct values). Generate
    a new list with evenly spaced values.
    """
    item_counts.sort(reverse=True)
    unplaced = sum(item_counts)
    placements = [None] * unplaced
    for item_type, item_count in enumerate(item_counts):
        instance = 0
        blank_count = -1
        for position in range(len(placements)):
            if placements[position] is None:
                blank_count += 1
                if blank_count * item_count // unplaced == instance:
                    placements[position] = item_type
                    instance += 1
        unplaced -= item_count
    return placements
