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. big+=1
  15. temp.append(x)
  16. elif x==']':
  17. big-=1
  18. temp.append(x)
  19. elif x=='(':
  20. small+=1
  21. temp.append(x)
  22. elif x==')':
  23. small-=1
  24. temp.append(x)
  25. if big<0 or small<0:
  26. var=False
  27. break
  28. for k in range(len(temp)-1):
  29. if( temp[k]=='(' and temp[k+1]==']') or ( temp[k]=='[' and temp[k+1]==')'):
  30. var=False
  31. if big==0 and small==0 and var==True:
  32. L.append('yes')
  33. else:
  34. L.append('no')
  35. for i in L:
  36. print(i)
Success #stdin #stdout 0.02s 9128KB
stdin
[[(([])])]
.
stdout
yes