2015/day10.py

28 lines
503 B
Python

import fileinput
input = [int(i) for i in next(fileinput.input()).strip()]
def solve(n):
global input
for _ in range(n):
new_input = []
current = input[0]
count = 0
for c in input:
if c == current:
count += 1
else:
new_input.extend((count, current))
current, count = c, 1
new_input.extend((count, current))
input = new_input
print(len(input))
solve(40)
solve(10)