Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def removeOne(st):
- foundGood = False
- i = len(st)-1
- while(i>0):
- if(st[i]=='}' and st[i-1]=='{'):
- st=st[0:i-1]+(st[i+1:] if(i!=len(st)-1) else '')
- foundGood = True
- else:
- if(st[i]==')' and st[i-1]=='('):
- st=st[0:i-1]+(st[i+1:] if(i!=len(st)-1) else '')
- foundGood = True
- else:
- if(st[i]==']' and st[i-1]=='['):
- st=st[0:i-1]+(st[i+1:] if(i!=len(st)-1) else '')
- foundGood = True
- if(i>len(st)-1):
- i=len(st) - 1
- else:
- i-=1
- if(foundGood):
- return st
- else:
- return '0'
- sk = str(input())
- while(sk!='0' and sk!=''):
- sk=removeOne(sk)
- if(sk==''):
- print('yes')
- else:
- print('no')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement