Skip to content

Commit 2ce9ce1

Browse files
10
1 parent bcf24f0 commit 2ce9ce1

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Diff for: 10.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
a = [1]
2+
3+
# calculate 30 values
4+
for i in range(1, 31):
5+
# a[i] base
6+
base = str(a[i - 1])
7+
base_len = len(base)
8+
result = "0"
9+
j = 0
10+
count = 1
11+
while j + 1 < base_len:
12+
if base[j + 1] == base[j]:
13+
count += 1
14+
j += 1
15+
else:
16+
result += str(count)
17+
result += str(base[j])
18+
j += 1
19+
count = 1
20+
if j + 1 == base_len:
21+
result += str(count)
22+
result += str(base[j])
23+
a.append(int(result))
24+
25+
print(a)
26+
print(len(str(a[30])))

Diff for: README.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# pythonchallenge
22
Solve Problems in http://www.pythonchallenge.com
33

4+
#### 10
5+
result: http://www.pythonchallenge.com/pc/return/5808.html
6+
7+
with pycharm IDE, I can debug the code easier.
8+
9+
the method of find rule of **a** is:look at **a[i - 1]**, do count
10+
1
11+
the next is one 1: 11
12+
the next is two 1: 21
13+
the next is one 2 one 1: 1211
14+
the next is one 1 one 2 two 2: 111221
15+
the next is three 1 two 2 one 1: 312211
16+
17+
418
#### 9
519
result:http://www.pythonchallenge.com/pc/return/bull.html
620

0 commit comments

Comments
 (0)