python challenge 10
1 #-*- coding:utf8-*-
2 import time
3 import re
4 start = time.time()
5 '''
6 a = [1, 11, 21, 1211, 111221,
7 len(a[30]) = ?
8 '''
9
10 def find_L(st):
11 nums = re.findall(r'1+|2+|3+|',st)
12 strs = ''
13 for i in nums:
14 if len(i):
15 strs += str(len(i)) + i[0]
16 return strs
17
18 i = 0
19 s = "1"
20 while i < 30:
21 s = find_L(s)
22 i += 1
23 print i
24 print len(s)
25 #5808
26 #耗时:0.0136680603027
27 print "耗时:"+str(time.time() - start)