def non_decreasing_series(n, size):
    '''Lists all combinations of 0,...,n-1 in increasing order'''

    if size == 1:
        return [[a] for a in range(n)]
    else:
        lc = non_decreasing_series(n, size-1)
        ll = []
        for l in lc:
            last = l[-1]
            for i in range(last, n):
                e = l + [i]
                ll.append(e)
        return ll
def non_decreasing_series ( n , size ) : if size == 1 : return [ [ a ] for a in range ( n ) ] else : lc = non_decreasing_series ( n , size - 1 ) ll = [ ] for l in lc : last = l [ - 1 ] for i in range ( last , n ) : e = l + [ i ] ll . append ( e ) return ll
Lists all combinations of 0,...,n-1 in increasing order