Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Brackets by Avaris
# migrated from python 2.7
def checkio(Expression):
'Check expression for correct brackets order'
x = "".join(a for a in Expression if a in "{}()[]")
while ("()" in x) or ("[]" in x) or ("{}" in x):
x=x.replace("()","")
x=x.replace("{}","")
x=x.replace("[]","")
return len(x)==0
if __name__ == '__main__':
assert checkio('({(asda)sd[s]d})') == True, 'First'
assert checkio('({[a]((s)})') == False, 'Second'
print('All ok')
May 1, 2011
Comments: