Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
By recursive function call. solution in Creative category for Brackets by Tinus_Trotyl
def scope(delim = ''):
global expr
flag = True
while expr and flag:
car, expr = expr[0], expr[1:]
if car == delim : return True
if car == '(' : flag = scope(')')
elif car == '[' : flag = scope(']')
elif car == '{' : flag = scope('}')
flag = flag and not(delim != car in ')]}')
return flag and (expr or not delim)
def checkio(expression):
global expr; expr = expression
return scope()
April 23, 2017
Comments: