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
Combinations with repetition
dataset/ETHPy150Open sympy/sympy/examples/intermediate/vandermonde.py/comb_w_rep