Advertisement
Bad_Programist

Untitled

Jan 27th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 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 >= 1:
  11.             c += 1
  12.             for j in range(c + 1):
  13.                 A.pop(i - c - 1)
  14.             res += c + 1
  15.             k = True
  16.             break
  17.         elif c >= 2:
  18.             for j in range(c + 1):
  19.                 A.pop(i - c - 1)
  20.             res += c + 1
  21.             k = True
  22.             break
  23.         else: c = 0
  24.     s = k
  25. print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement