** Funny Python Challenge programming puzzle game level 10 **
Introduction
game introduction
I usually learn python by myself. Everyone is definitely bored. I recommend a Python version of the game that is a long time ago-Python Challenge. Although this site is very early, it is very interesting. You will find these games are not simple at all. Basic All need to be solved through programming ...
Interestingly, this is a puzzle-solving game, so you need to be careful to find clues, solve the puzzle, and the amount of knowledge investigated is not very small, which is very interesting.
Game link:http://www.pythonchallenge.com/
The interface looks like this:
Click on the picture to Click here to get challenged
start the challenge.
0-4 pass guide
(Rank 0-4: Click here to view directly )
5-9 level guide
(Ranks 5-9: Click here to view directly )
Write in front
I originally planned to write 5 levels for each essay, but I found that the later became more and more difficult. The original plan was difficult to achieve, and it was very time-consuming to write, wasting a lot of energy. ...
Level 10
The prompt for this level is simple, calculate the length, but where is a? View the source code:
href="sequence.txt" />
Here is a text, open it and see
a = [1, 11, 21, 1211, 111221,
Very simple, a is here. In fact, if you click on the cow in the picture, you can also get this result.
Programming solution:
s='1'
for j in range(30):
t=0
g=[]
num=0
n=[]
for i in range(len(s)):
if t!=s[i]:
g.append(s[i])
if num !=0:
n.append(num)
num=0
num+=1
t=s[i]
if i ==len(s)-1:
n.append(num)
s=''
for x in range(len(n)):
s+=str(n[x])
s+=g[x]
print('len(a['+str(j+1)+']):',len(s))
In fact, there are many big names on the Internet, and their code is very simple, but I want to use some basic syntax to solve it.
Harmful, I really wrote bad code.
See the results:
len(a[1]) : 2
len(a[2]) : 2
len(a[3]) : 4
len(a[4]) : 6
len(a[5]) : 6
len(a[6]) : 8
len(a[7]) : 10
len(a[8]) : 14
len(a[9]) : 20
len(a[10]) : 26
len(a[11]) : 34
len(a[12]) : 46
len(a[13]) : 62
len(a[14]) : 78
len(a[15]) : 102
len(a[16]) : 134
len(a[17]) : 176
len(a[18]) : 226
len(a[19]) : 302
len(a[20]) : 408
len(a[21]) : 528
len(a[22]) : 678
len(a[23]) : 904
len(a[24]) : 1182
len(a[25]) : 1540
len(a[26]) : 2012
len(a[27]) : 2606
len(a[28]) : 3410
len(a[29]) : 4462
len(a[30]) : 5808
Obviously, the answer is 5808, so I get the new url:
Results link
http://www.pythonchallenge.com/pc/return/5808.html
Trailer 11
Everyone guess: odd even
what does it mean? ? ? ? ? ? ? ? ? ? ?