-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlevel10.py
More file actions
executable file
·42 lines (37 loc) · 807 Bytes
/
level10.py
File metadata and controls
executable file
·42 lines (37 loc) · 807 Bytes
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
#!/usr/bin/python
import urllib
import re
import math
a = [1, 11, 21, 1211, 111221]
def seq(n):
if n == 1:
b.append(a[0])
return a[0]
elif n < 1:
return "Please Input a right number!"
new = say(str(seq(n - 1)))
print "the",n - 1,"number's length is",len(str(new))
b.append(new)
return new
def say(num):
seqs = ""
print "length is:",len(num)
while len(num) > 0:
tn = num[0]
cn = 0
while (cn < len(num) and num[cn] == tn):
cn += 1
seqs += str(cn) + str(tn)
if cn == len(num):
break
else:
num = num[cn:]
return int(seqs)
print a
while True:
b = []
n = raw_input("Input a number:")
if int(n) == 0:
break
print seq(int(n))
print b