Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I fixed this myself but in case anyone is interested I will leave this as an answer.

I decided to use the kbits from this thread to generate all binary strings of length $n$ with $m$ ones. Such strings are in a natural bijection with $NE$-lattice paths from $(0,0)$ to $(n,m)$. After that, I can get the heights of all the paths by writing

Paths = WordPaths('01', steps=[(1,-1),(1,1)])

for b in kbits(m+n,m):

Note: Sage has a "height" function on words, but this is not what I am looking for. In the definition of height that I am using, the height of an $NE$-path is geometrically the biggest distance that the path is away from the main diagonal.