fork download
  1. L=[]
  2. while True:
  3. big=0
  4. small=0
  5. a=input()
  6. var=True
  7. if (a=='.'):
  8. break
  9. else:
  10. temp=[]
  11. var=True
  12. for x in a:
  13. if x=='.':
  14. break
  15. if x=='[':
  16. big+=1
  17. temp.append(x)
  18. elif x==']':
  19. big-=1
  20. temp.append(x)
  21. elif x=='(':
  22. small+=1
  23. temp.append(x)
  24. elif x==')':
  25. small-=1
  26. temp.append(x)
  27. if big<0 or small<0:
  28. var=False
  29. break
  30. for k in range(len(temp)-1):
  31. if( temp[k]=='(' and temp[k+1]==']') or ( temp[k]=='[' and temp[k+1]==')'):
  32. var=False
  33. if big==0 and small==0 and var==True:
  34. L.append('yes')
  35. else:
  36. L.append('no')
  37. for i in L:
  38. print(i)
Success #stdin #stdout 0.02s 9168KB
stdin
.[]][
.
stdout
yes