Advertisement
Bad_Programist

Untitled

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