30 lines
621 B
Python
30 lines
621 B
Python
from lib import get_data
|
|
|
|
data = get_data(__file__)
|
|
|
|
|
|
def iter(xs):
|
|
if not xs:
|
|
return []
|
|
grouped = []
|
|
current_element = xs[0]
|
|
count = 1
|
|
for element in xs[1:]:
|
|
if element == current_element:
|
|
count += 1
|
|
else:
|
|
grouped.append(count)
|
|
grouped.append(current_element)
|
|
current_element = element
|
|
count = 1
|
|
grouped.append(count)
|
|
grouped.append(current_element)
|
|
return grouped
|
|
|
|
|
|
for repeat in [40, 50]:
|
|
xs = list(map(int, list(data.strip())))
|
|
for _ in range(repeat):
|
|
xs = iter(xs)
|
|
print(len(xs))
|