Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Brackets by TovarischZhukov
def checkio(expression):
starts = []; ends = []
for elem in expression:
if elem in "{[(": starts.append(elem)
if elem in "}])":
if starts and starts[-1]!= {"}":"{",")":"(","]":"["}[elem]:
return False
else:
if starts:
del starts[-1]
else:
return False
return starts ==[]
Dec. 5, 2015