Gapplet

Let A be the free monoid on the alphabet {(,)}, that is, the two letters ( and ). We call an element of A balanced if, for any of its left subwords, the number of opening brackets is at least the number of closing brackets. The set of all balanced words is a submonoid of A. Explore this submonoid by writing down all words of a given length.

Input the length of a balanced word g 
e.g., 6
</COMMENT>
 
Find out about the number of balanced words of this length
</COMMENT>
 
</COMMENT>
 
 
Input a balanced word of the specified length, 
e.g., "()()()" for length 6.
</COMMENT>
 
Find out about the number of balanced words of this length
</COMMENT>
 
</COMMENT>