Puzzle du 10 décembre 2015
This commit is contained in:
parent
960ef10877
commit
87ed25ca64
|
@ -0,0 +1,18 @@
|
|||
#!/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))
|
Loading…
Reference in New Issue