def slots(n, k, normalized=False):
    """Generates distributions of n identical items into k distinct slots.

    A generator over distributions of n indistinguishable items into k
    distinguishable slots, where each slot can hold up to n items.
    Selection of items is done without replacement, and the order within the
    slots cannot matter since the items are indistinguishable.

    The number of distributions is (n + k - 1)! / n! / (k-1)!

    Parameters
    ----------
    n : int
        The number of indistinguishable items.
    k : int
        The number of distinguishable slots.
    normalized : bool
        If True, then we divide each term in the tuple by the number of items.
        The default value is False.

    Yields
    ------
    t : tuple
        A tuple of length k where each element is an integer representing
        the number of indistinguishable items within the slot.

    Examples
    --------
    >>> list(slots(3,2))
    [(0, 3), (1, 2), (2, 1), (3, 0)]

    """
    seq, i = [n] * k + [0], k
    if normalized:
        nf = float(n)
        while i:
            yield tuple((seq[i] - seq[i + 1]) / nf for i in range(k))
            i = seq.index(0) - 1
            seq[i:k] = [seq[i] - 1] * (k - i)
    else:
        while i:
            yield tuple(seq[i] - seq[i + 1] for i in range(k))
            i = seq.index(0) - 1
            seq[i:k] = [seq[i] - 1] * (k - i)
