Advertisement
Bad_Programist

Untitled

Jan 28th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. A = list(map(int, input().split()))
  2. s = True
  3. res = 0
  4. while s:
  5.     c = 0
  6.     i = 1
  7.     k = False
  8.     while i < len(A):
  9.         if A[i] == A[i - 1] and i != len(A) - 1:
  10.             c += 1
  11.         elif i == len(A) - 1 and A[i] == A[i - 1] and c >= 1:
  12.             c += 1
  13.             for j in range(c + 1):
  14.                 A.pop(i - c - 1)
  15.             k = True
  16.             res += c + 1
  17.             i -= c + 1
  18.             break
  19.             c = 0
  20.         elif c >= 2:
  21.             for j in range(c + 1):
  22.                 A.pop(i - c - 1)
  23.             k = True
  24.             res += c + 1
  25.             break
  26.             i -= c + 1
  27.             c = 0
  28.         else:
  29.             c = 0
  30.         i += 1
  31.     s = k
  32. print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement