Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Brackets by Kamyfator
def checkio(expr):
stack = []
for c in expr:
if c in set(["{", "[", "("]):
stack.append(c)
if c == "}":
if len(stack) <= 0 or stack[-1] != "{":
return False
stack.pop()
if c == "]":
if len(stack) <= 0 or stack[-1] != "[":
return False
stack.pop()
if c == ")":
if len(stack) <= 0 or stack[-1] != "(":
return False
stack.pop()
if len(stack) > 0:
return False
return True
Oct. 24, 2016