Balanced brackets: Difference between revisions

Content added Content deleted
m (→‎{{header|Python}}: Formatting)
Line 103: Line 103:
...
...
>>> for txt in (gen(N) for N in range(10)):
>>> for txt in (gen(N) for N in range(10)):
... print ("%r is%s balanced" % (txt, '' if balanced(txt) else ' not'))
... print ("%-22r is%s balanced" % (txt, '' if balanced(txt) else ' not'))
...
...
'' is balanced
'' is balanced
'][' is not balanced
'[]' is balanced
'[][]' is balanced
'[][]' is balanced
'[[]]][' is not balanced
'][[[]]' is not balanced
'][[[][]]' is not balanced
'[]][[][]' is not balanced
'][[[][]]][' is not balanced
'[][[][]]][' is not balanced
'][[]][][][][' is not balanced
'][]][][[]][[' is not balanced
'][[]]]][[[][[]' is not balanced
'[[]]]]][]][[[[' is not balanced
'[[[]][]][][]][[]' is not balanced
'[[[[]][]]][[][]]' is balanced
'[[[[[][[[]][]]]]]]' is balanced</lang>
'][[][[]]][]]][[[[]' is not balanced</lang>


=={{header|Tcl}}==
=={{header|Tcl}}==