1
0
Fork 0
adventofcode/2015/10/elves.py

19 lines
432 B
Python
Executable File

#!/usr/bin/env python3
import sys
number = sys.argv[1]
def gen_number(num):
current, count, output = num[0], 1, ''
for digit in num[1:]:
if digit != current:
output += str(count) + current
current, count = digit, 1
else:
count += 1
output += str(count) + current
return output
for _ in range(int(sys.argv[2])):
number = gen_number(number)
print(len(number))