In [12]:
#!/usr/bin/python
from itertools import groupby
In [13]:
def lookandsay( instr ):
newstr = ""
repeats = [list(g) for k, g in groupby(str( instr ))]
for group in repeats:
newstr += str(len(group)) + str(group[0])
return newstr
In [14]:
input = "1321131112"
n = 40 #star 1 input
#n = 50 #star 2 input
for r in range(n):
input = lookandsay ( input )
print (len(input))
In [ ]:
In [ ]: