Advertisement
Bad_Programist

Untitled

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