|   | 1 |  initial version  | 
As you can see, d is a kind of discrete primitive of w. So you can compute it as follows:
sage: def primitive(w):
....:     height = 0
....:     d = [height]
....:     for i in w:
....:         if i == 1:
....:             height += 1
....:             d.append(height)
....:         else:
....:             height -= 1
....:             d.append(height)
....:     return d
sage: w=[1,1,1,0,0,1,0,0]    
sage: primitive(w)
[0, 1, 2, 3, 2, 1, 2, 1, 0]
You can get its height as follows:
sage: max(primitive(w))
3
|   | 2 |  No.2 Revision  | 
As you can see, d is a kind of discrete primitive of w. So you can compute it as follows:
sage: def primitive(w):
....:     height = 0
....:     d = [height]
....:     for i in w:
....:         if i == 1:
....:             height += 1
....:             d.append(height)
....:         else:
....:             height -= 1
....:             d.append(height)
....:     return d
sage: w=[1,1,1,0,0,1,0,0]    
sage: primitive(w)
[0, 1, 2, 3, 2, 1, 2, 1, 0]
You can get its height as follows:
sage: max(primitive(w))
3
You can get all primitives of all Dyck words of a given length as follows:
sage: [primitive(w) for w in DyckWords(4)] [[0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 2, 1, 0], [0, 1, 0, 1, 2, 1, 0, 1, 0], [0, 1, 0, 1, 2, 1, 2, 1, 0], [0, 1, 0, 1, 2, 3, 2, 1, 0], [0, 1, 2, 1, 0, 1, 0, 1, 0], [0, 1, 2, 1, 0, 1, 2, 1, 0], [0, 1, 2, 1, 2, 1, 0, 1, 0], [0, 1, 2, 1, 2, 1, 2, 1, 0], [0, 1, 2, 1, 2, 3, 2, 1, 0], [0, 1, 2, 3, 2, 1, 0, 1, 0], [0, 1, 2, 3, 2, 1, 2, 1, 0], [0, 1, 2, 3, 2, 3, 2, 1, 0], [0, 1, 2, 3, 4, 3, 2, 1, 0]]
Hence you can get the set of heights as follows:
sage: {max(primitive(w)) for w in DyckWords(4)}
{1, 2, 3, 4}
|   | 3 |  No.3 Revision  | 
As you can see, d is a kind of discrete primitive of w. So you can compute it as follows:
sage: def primitive(w):
....:     height = 0
....:     d = [height]
....:     for i in w:
....:         if i == 1:
....:             height += 1
....:             d.append(height)
....:         else:
....:             height -= 1
....:             d.append(height)
....:     return d
sage: w=[1,1,1,0,0,1,0,0]    
sage: primitive(w)
[0, 1, 2, 3, 2, 1, 2, 1, 0]
You can get its height as follows:
sage: max(primitive(w))
3
You can get all primitives of all Dyck words of a given length as follows:
Hence you can get the set of heights as follows:
sage: {max(primitive(w)) for w in DyckWords(4)}
{1, 2, 3, 4}
 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.