Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Brackets by ClementBC
def checkio(s):
pile = []
for x in s:
if x in ['{', '(', '[']:
pile.append(x)
if x == '}' and (pile == [] or pile.pop() != '{'):
return(False)
if x == ']' and (pile == [] or pile.pop() != '['):
return(False)
if x == ')' and (pile == [] or pile.pop() != '('):
return(False)
return(pile == [])
April 19, 2016