26 lines
427 B
Text
26 lines
427 B
Text
|
|
# by Artyom Bologov
|
||
|
|
H
|
||
|
|
# Remove all the non-bracket chars
|
||
|
|
g/.*/s/[^][]//gp
|
||
|
|
# Repeatedly remove all the simple matching brackets.
|
||
|
|
# Add more lines to handle deeper nested expressions.
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/\[\]/s///g
|
||
|
|
g/./s/.*/Not balanced!/
|
||
|
|
g/^$/s/.*/Balanced!/
|
||
|
|
,p
|
||
|
|
Q
|