(n, k)
return combs
Combinations with repetition

    Returns the list of k combinations with repetition from n objects.
Combinations with repetition
Combinations with repetition
def comb_w_rep(n, k):
    """Combinations with repetition

    Returns the list of k combinations with repetition from n objects.
    """
    if k == 0:
        return [[]]
    combs = [[i] for i in range(n)]
    for i in range(k - 1):
        curr = []
        for p in combs:
            for m in range(p[-1], n):
                curr.append(p + [m])
        combs = curr
    return combs
def comb_w_rep ( n , k ) : if k == 0 : return [ [ ] ] combs = [ [ i ] for i in range ( n ) ] for i in range ( k - 1 ) : curr = [ ] for p in combs : for m in range ( p [ - 1 ] , n ) : curr . append ( p + [ m ] ) combs = curr return combs