Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is a try

 def all_paths(n):
    W0 = Word([0] * n)
    W1 = Word([1] * n)
    G = Graphics()
    N = QQ(binomial(2 * n, n))
    col = rainbow(N)
    shift = vector([1/N, -1/N])
    right = vector([0, 1])
    up = vector([1, 0])
    zero = vector([0, 0])
    for k, word in enumerate(W0.shuffle(W1)):
        path = [right if l else up for l in word]
        coords = []
        z = zero
        for x in path:
            z += x
            coords.append(z)
        G += line2d(coords, color=col[k])
        zero += shift
    return G