one-file-projects/looknsay.py

25 lines
406 B
Python

def looknsay(n):
s = str(n)
sn = ""
q = 0
c = None
for x in s:
if c != x:
if q > 0:
sn += "%d%s" % (q,c)
q = 1
c = x
else:
q+=1
if q > 0:
sn += "%d%s" % (q,c)
return int(sn)
if __name__ == "__main__":
c = 1
print(c)
for i in range(5):
c = looknsay(c)
print(c)