Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Brackets by martin_b
def checkio(expression):
OPENING, CLOSING, stack = "{[(", "}])", []
for c in expression:
if c in OPENING:
stack.append(c)
elif c in CLOSING:
if not stack or CLOSING.index(c) != OPENING.index(stack.pop()):
return False
return not stack
Sept. 25, 2016