the python challenge
来源:互联网 发布:晴天软件 编辑:程序博客网 时间:2024/06/05 10:00
1: 第一题:图片左左上角为0 html 地址为0.html 图片内容为 2的38次幂 利用python 2 ** 38 得出 274877906944 替换地址栏中的0得出下一页地址:http://www.pythonchallenge.com/pc/def/274877906944 .html
2:第二题为加密解密问题 :
enc_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."
out_str = ""
for letter in enc_str:
letter_ = ord(letter) + 2
if ord(letter) >= 97 and ord(letter) <= 122:
if letter_ >= 122:
letter_ = letter_ - 26
print chr(letter_)
out_str += chr(letter_)
else:
out_str += letter
print out_str
为: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. using string.maketrans() is recommended. now apply on the url.
将地址中map 按照图片的加密算法 得出下一页地址:http://www.pythonchallenge.com/pc/def/ocr.html
3,查看页面源代码。可以看到一大最的特殊字符。根据提示是找出所有字母中频率最少的的字母,我用了一个比较笨的办法,得出equality:
with open("cha3.txt", "r") as f:
file_content = f.read()
rate_dict = {}
for letter in file_content:
if letter in rate_dict:
rate_dict[letter] = rate_dict[letter] +1
else:
rate_dict[letter] = 1
4: 第四题是正在表达式问题 ,找出一个小写字母 并且两边各有三个大写字母, 得出linkedlist。
import re
file_content = ""
with open("cha4.txt", "r") as f:
file_content = f.read()
test_re = re.compile(r'[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]')
result = test_re.findall(file_content)
if result:
print "".join(result)
5:
import urllib2
need_devide =True
def get_nothing():
nothing = 69288
for x in xrange(400):
url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s" % nothing
content = urllib2.urlopen(url).read()
nothing = content.split(" ")[-1]
print x, nothing, content
if not nothing.isdigit():
if need_devide:
nothing = int(nothing) / 2
need_devide = False
else:
break
if __name__ == "__main__":
get_nothing()
- 涉水The Python Challenge
- The python challenge 00
- The python challenge 01
- the python challenge
- The Python Challenge
- the python challenge 解答
- The Python Challenge 题解
- The Python Challenge 0~2
- The Python Challenge Level 0-1 Solutions
- The Python Challenge Level-2 Solution
- The Python Challenge Level-6 Solution
- The Python Challenge Level-3 Solution
- The Python Challenge Level-4 Solution
- The Python Challenge Level-5 Solution
- The Python Challenge Level-7 Solution
- The Python Challenge Level-8 Solution
- The Python Challenge Level 9-10 Solutions
- The Python Challenge Level-11 Solution
- java后端系统架构之服务治理篇:dubbo的实验
- 工商银行拥抱互联网的“e-难题”
- C#stringBuilder用法
- Struts2.3.16.1+Hibernate4.3.4+Spring4.0.2 框架整合
- 浅谈算法和数据结构: 四 快速排序
- the python challenge
- Hook钩子技术
- 又拍网架构中的数据库分库设计
- 进程 与 线程
- hdu 3810 Magina 队列优化的0-1背包t
- 黑马程序员——Java高新知识——反射
- 浅谈算法和数据结构: 五 优先级队列与堆排序
- 行列式 与 n维平行多面体体积 公式的证明 determinant volume proof
- 等级渲染