Advertisement
Fargoth_Cor

Untitled

Oct 28th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1.  
  2. a = str(input())
  3. b = []
  4. k = -1
  5. g = 1
  6. for i in range(len(a)):
  7.     if a[i] == 'A':
  8.         if a[i - 1] != 'A':
  9.             k += 1
  10.             b.append(g)
  11.         else:
  12.             b[k] += 1
  13. res = ''
  14. i = 0
  15. f = 0
  16. while i < len(b):
  17.     if str(b[i]) not in res:
  18.         res += str(b[i])
  19.         f += 1
  20.     else:
  21.         s = str(b[i])
  22.         while (i < len(b)) and (s in res):
  23.  
  24.             s += str(b[i])
  25.             i += 1
  26.         res += s
  27.         if i < len(b):
  28.             f += 1
  29.     i += 1
  30. print(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement