#!/usr/bin/python import sys import string def seq(x):
result =''
i = 0 while i < len(x):
#print'i:',i,x[i]
p = x[i]
j = 0 while i+j<len(x)and x[i+j]==p:
j+=1
result+=str(j)
result+=p
i = i+j return result
def main():
a=[]
x ='1' for i in range(30):
a.append(seq(x))
x = seq(x) print i+1,len(x)
if__name__=='__main__':
main()
贴一段别人的代码:这就是差距。
x="1" for each in range(30):
x="".join([str(len(i+j))+i for i,j in re.findall(r"(\d)(\1*)", x)]) print len(x)