Bracket Matching by SeeNoEvil

while 1:
 s=[];p=e=0;i=raw_input()
 for c in i:
\x09b=")]}>([{".find(c)
\x09if b/4:s+=[b%4]
\x09elif b%4-s.pop():e=i[p:];break
\x09p+=1
 print(s or e)and"failed at: "+(e or"EOL")or"yes"

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page