网址:http://www.pythonchallenge.com/
解答好文:http://story.iteye.com/blog/730466

0:2^38

1 reduce(lambda x,y:x*y,[2]*38)   #输入时不要输入L,只是表示类型为Long

 

1:位移两位

 1 import string
 2  str="g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
 3  transfun=string.maketrans('abcdefghijklmnopqrstuvwxyz','cdefghijklmnopqrstuvwxyzab')
 4  print str.translate(transfun)
 5  -->
 6     i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long.
 7     using string.maketrans() is recommended. now apply on the url.
 8     
 9  *ord('A')可转化为ASCII码,chr(65)可转化为字符
10   但是注意最后两位y与Z不能用ASCII+2而是对应到a,b

 

2:page source即是源代码里面,写的有找最少
 将那些字符复制到同路径名字为data的文件夹,采用伪木桶算法,这样每次操作都是O(1)

 1 a={}
 2 eleL=set(list('equality#)^)&!_+]!*@&^}@[@%]()%+$&[(_@%+%$*^@$^!+]!&_#)_*}{}}!}_]$[%}@[{_@#_^{*@##&{#&{&)*%(]{{([*}@[@&]+!!*{)!}{%+{))])[!^})+)$]#{*+^((@^@}$[**$&^{$!@#$%)!@(&+^!{%_$&@^!}$_${)$_#)!({@!)(^}!*^&!$%_&&}&_#&@{)]{+)%*{&*%*&@%$+]!*__(#!*){%&@++'))
 3 for i in eleL:
 4     a[i] = 0
 5 
 6 with open('data','r') as f:
 7     str=''
 8     for line in f.readlines():        #最好一行一行的处理,一起读出来太大容易卡电脑
 9         line = list(line.strip())   #strip去掉换行符
10         for i in line:
11             a[i]+=1
12     print(a)
13 最后发现有几个字母都是只出现了一次:equality
14 **其实有个bug,equality这个词通过写是报Keyerror即可看出来了!!!第二行我是复制了三行进去再用set去重,报keyerror我才添加equality进去的

 

3:One small letter, surrounded by EXACTLY three big bodyguards on each of its sides:
找到一个周围被三个大写字母包围的小写字母(网页源代码中)

1 import re
2 with open('data','r') as f:
3     str = f.read().strip()
4     res=''.join()re.findall(r'[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]',str))  #findall方法返回每个字母组成的list,[^]为不包含的意思
5     if(res):
6         print(res)
7 --->linkedlist

 

4:先点击图片后发现是个多级跳转,第一个参数是33110

 1 from urllib import request
 2 import re
 3 value=33110
 4 while True:
 5     with request.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%d'%value) as f:
 6         data = f.read().decode('utf-8')
 7         res = re.findall(r'(\d+)',data)
 8         value = int(res[0])
 9         print(value)
10 最后得到66831,跳转后得到peak.html

 

5:这道题太扯了,peak hell连读成了pickle,pickle虽然知道但是从来没用过。
  参考:    
  将page source里点击banner.p出现的东西保存成文件banner.p放到同目录下
  序列化后出来是[[(' ', 95)], [(' ', 14), ('#', 5), (' ', 70), ('#', 5), (' ', 1)], [(' ', 15), ('#',   4)]...]]根本就不知道是啥
  输出成如下格式后:

 1 [[(' ', 95)], [(' ', 14), ('#', 5), (' ', 70), ('#', 5), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)], [(' ', 6), ('#', 3), (' ', 6), ('#', 4), (' ', 3), ('#', 3), (' ', 9), ('#', 3), (' ', 7), ('#', 5), (' ', 3), ('#', 3), (' ', 4),
 2 [(' ', 95)]
 3 [(' ', 14), ('#', 5), (' ', 70), ('#', 5), (' ', 1)]
 4 [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
 5 [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
 6 [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
 7 [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
 8 [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
 9 [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
10 [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
11 [(' ', 6), ('#', 3), (' ', 6), ('#', 4), (' ', 3), ('#', 3), (' ', 9), ('#', 3), (' ', 7), ('#', 5), (' ', 3), ('#', 3), (' ', 4), ('#', 5), (' ', 3), ('#', 3), (' ', 10), ('#', 3), (' ', 7), ('#', 4), (' ', 1)]
12 [(' ', 3), ('#', 3), (' ', 3), ('#', 2), (' ', 4), ('#', 4), (' ', 1), ('#', 7), (' ', 5), ('#', 2), (' ', 2), ('#', 3), (' ', 6), ('#', 4), (' ', 1), ('#', 7), (' ', 3), ('#', 4), (' ', 1), ('#', 7), (' ', 5), ('#', 3), (' ', 2), ('#', 3), (' ', 5), ('#', 4), (' ', 1)]
13 [(' ', 2), ('#', 3), (' ', 5), ('#', 3), (' ', 2), ('#', 5), (' ', 4), ('#', 4), (' ', 3), ('#', 3), (' ', 3), ('#', 4), (' ', 4), ('#', 5), (' ', 4), ('#', 4), (' ', 2), ('#', 5), (' ', 4), ('#', 4), (' ', 3), ('#', 3), (' ', 5), ('#', 3), (' ', 3), ('#', 4), (' ', 1)]
14 [(' ', 1), ('#', 3), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 3), ('#', 3), (' ', 4), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 6), ('#', 4), (' ', 2), ('#', 4), (' ', 1)]
15 [(' ', 1), ('#', 3), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 10), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 7), ('#', 3), (' ', 2), ('#', 4), (' ', 1)]
16 [('#', 4), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 5), ('#', 2), (' ', 3), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 7), ('#', 3), (' ', 2), ('#', 4), (' ', 1)]
17 [('#', 4), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 3), ('#', 10), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 14), (' ', 2), ('#', 4), (' ', 1)]
18 [('#', 4), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 4), ('#', 4), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 12), ('#', 4), (' ', 1)]
19 [('#', 4), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 5), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 12), ('#', 4), (' ', 1)]
20 [(' ', 1), ('#', 3), (' ', 11), ('#', 4), (' ', 5), ('#', 4), (' ', 1), ('#', 4), (' ', 5), ('#', 3), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 12), ('#', 4), (' ', 1)]
21 [(' ', 2), ('#', 3), (' ', 6), ('#', 2), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 3), (' ', 4), ('#', 4), (' ', 4), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 3), ('#', 3), (' ', 6), ('#', 2), (' ', 3), ('#', 4), (' ', 1)]
22 [(' ', 3), ('#', 3), (' ', 4), ('#', 2), (' ', 3), ('#', 4), (' ', 5), ('#', 4), (' ', 3), ('#', 11), (' ', 3), ('#', 4), (' ', 5), ('#', 4), (' ', 2), ('#', 4), (' ', 5), ('#', 4), (' ', 4), ('#', 3), (' ', 4), ('#', 2), (' ', 4), ('#', 4), (' ', 1)]
23 [(' ', 6), ('#', 3), (' ', 5), ('#', 6), (' ', 4), ('#', 5), (' ', 4), ('#', 2), (' ', 4), ('#', 4), (' ', 1), ('#', 6), (' ', 4), ('#', 11), (' ', 4), ('#', 5), (' ', 6), ('#', 3), (' ', 6), ('#', 6)]
24 [(' ', 95)]
View Code

相关文章: