(n)
Integer partitions of n, in reverse lexicographic order.
    The output and asymptotic runtime are the same as mckay(n),
    but the algorithm is different: it involves no division,
    and is simpler than mckay, but uses O(n) extra space for
    a recursive call stack.
Integer partitions of n, in reverse lexicographic order.
    The output and asymptotic runtime are the same as mckay(n),
    but the algorithm is different: it involves no division,
    and is simpler than mckay, but uses O(n) extra space for
    a recursive call stack.
Integer partitions of n in reverse lexicographic order . The output and asymptotic runtime are the same as mckay ( n ) but the algorithm is different : it involves no division and is simpler than mckay but uses O ( n ) extra space for a recursive call stack .
def revlex_partitions(n):
    """
    Integer partitions of n, in reverse lexicographic order.
    The output and asymptotic runtime are the same as mckay(n),
    but the algorithm is different: it involves no division,
    and is simpler than mckay, but uses O(n) extra space for
    a recursive call stack.
    """

    if n == 0:
        yield []
    if n <= 0:
        return
    for p in revlex_partitions(n-1):
        if len(p) == 1 or (len(p) > 1 and p[-1] < p[-2]):
            p[-1] += 1
            yield p
            p[-1] -= 1
        p.append(1)
        yield p
        p.pop()
def revlex_partitions ( n ) : if n == 0 : yield [ ] if n <= 0 : return for p in revlex_partitions ( n - 1 ) : if len ( p ) == 1 or ( len ( p ) > 1 and p [ - 1 ] < p [ - 2 ] ) : p [ - 1 ] += 1 yield p p [ - 1 ] -= 1 p . append ( 1 ) yield p p . pop ( )