Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. def removeOne(st):
  2.     foundGood = False
  3.     i = len(st)-1
  4.     while(i>0):
  5.         if(st[i]=='}' and st[i-1]=='{'):
  6.             st=st[0:i-1]+(st[i+1:] if(i!=len(st)-1) else '')
  7.             foundGood = True
  8.         else:
  9.             if(st[i]==')' and st[i-1]=='('):
  10.                 st=st[0:i-1]+(st[i+1:] if(i!=len(st)-1) else '')
  11.                 foundGood = True
  12.             else:
  13.                 if(st[i]==']' and st[i-1]=='['):
  14.                     st=st[0:i-1]+(st[i+1:] if(i!=len(st)-1) else '')
  15.                     foundGood = True
  16.         if(i>len(st)-1):
  17.             i=len(st) - 1
  18.         else:
  19.             i-=1
  20.     if(foundGood):
  21.         return st
  22.     else:
  23.         return '0'
  24.  
  25. sk = str(input())
  26.  
  27. while(sk!='0' and sk!=''):
  28.     sk=removeOne(sk)
  29. if(sk==''):
  30.     print('yes')
  31. else:
  32.     print('no')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement