fork download
  1. class UserMainCode(object):
  2. @classmethod
  3. def swaps(cls,input1):
  4. '''
  5. input1:string
  6. Expected return type:int
  7. '''
  8. input1=list(input1)
  9. res=0
  10. while input1:
  11. i=input1.index(input1[-1])
  12. if i == len(input1)-1:
  13. res+=i/2
  14. else:
  15. res+=i;
  16. input1.pop(i)
  17. input1.pop()
  18. print(int(res))
  19. obj = UserMainCode()
  20. obj.swaps(input())
  21.  
Success #stdin #stdout 0.02s 9048KB
stdin
ntiin
stdout
1