-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path10th.py
45 lines (38 loc) · 1.25 KB
/
10th.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
######################################################################
## Filename: 10th.py
##
## Copyright (c) 2012,Yannis
## Version:
## Author: Yannis.Xu <[email protected]>
## Created at: Wed Feb 29 06:51:40 2012
##
## Description:
##
######################################################################
#查看源代码,根据提示 打开sequence.txt, 看到的结果是 a=[1, 11, 21, 1211, 111221 , 根据bull.html页面的提示 len(a[30]) 求解
#数字的规律是后一个描述前一个,比如 11指前面1个1,21是指前面2个1,1211是指前面1个2,1个1,111221指前面1个1,1个2,2个1,根据提示得出312211
import string
startstr = "1"
count = 0
newstr = ""
for i in range(30):
temp = startstr[0]
for j in startstr:
if temp == j:
count += 1
else:
if count == 0:
count += 1
newstr += str(count)
newstr += temp
count = 1
temp = j
newstr += str(count)
newstr += temp
count = 0
print "第 %d 次循环" %(i)
print newstr
startstr = newstr
newstr = ""
print "结果为"
print len(startstr)