Bracket Matching by recursive

def b(m):
 if m:print m
 s=raw_input();l=[];f='failed at: '
 while s:c='({[<)}]>'.find(s[0]);l+=[c]*(c<4or l.pop()-c+4and b(f+s));s=s[1:]
 b(l and f+'EOL'or'yes')
b(0)

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

download

return to the top page