0. 2的38次方

 print 2**38
 ##apply the result to the url

1. 看图是要right shift两位, 切片即可。

 import string

 intab = string.ascii_lowercase
 outtab = intab[2:] + intab[:2]
 trans_table = string.maketrans(intab, outtab)

 s = """
     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."""

 print s.translate(trans_table)
 print 'map'.translate(trans_table)

 ##The result is
 ##
 ##    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.
 ##ocr

 ##apply ocr to the url

2. 寻找出现次数少的character

 import string

 result = {}
 text = open('003help.txt').read()
 for ch in text:
     result[ch] = result.get(ch, 0) + 1

 print result
 print ''.join(ch for ch in result if result[ch]==1)
 s = []
 for i in text:
     if i in string.ascii_lowercase:
         s.append(i)
 print ''.join(s)

 ##apply 'equality' to the url

3. One small letter, surrounded by EXACTLY three big bodyguards on each of its sides. 正则表达式!

import re

pattern = re.compile('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]')
text = open('004help.txt').read()

t = re.findall(pattern, text)
print ''.join(t)

##apply to the url

4. follow the chain. 还是回到网页源代码,发现linkedlist.php?nothing=12345,替代linkedlist.php然后得到the next nothing is  .其实就是从这个网页中提取nothing后面的数字替换,作者说不超过400次,加一个for循环,如下:

 import re
 import urllib

 url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
 nothing = '
 pattern = re.compile(r'and the next nothing is (\d+)')
 for i in range(400):
     try:
         text = urllib.urlopen(url+nothing).read()
         nothing = pattern.findall(text)[0]
         print nothing
     except Exception, e:
         print e
         break
 print text

中间又一次exception,16044,让除以2,改成8022,继续,最后得到peak.html。

5. pronounce it. 读了好长时间,也没有神奇的事情发生,后来bing了才知道peakhell --> pickle. 也在我学识浅薄,没学习过这个模块。查了一下pickle的文档,这是一个python对象序列化的模块,感觉很抽象,好在api不复杂,页面源码提供了peakhell src,就是那个banner.p下载下来之后,用loads函数进行处理,下面是loads函数的说明(注意,不是load()):

pickle.loads(string)
Read a pickled object hierarchy from a string. Characters in the string past the pickled object’s representation are ignored.

 #cPickle是c语言实现的pickle模块
 import cPickle as pickle

 t = open('banner.p').read()
 s = pickle.loads(t)
 print s

结果是一个list,研究了半天只知道列和95(小学生思维)。这下更摸不着头脑了,只好__人有两件宝,双手和电脑__去搜索答案了。Amazing!

 for line in s:
     print ''.join(map(lambda pair: pair[0]*pair[1], line))

try it, try it! 不禁让我想到linuxlogo,这种ascii图还很养眼。

不过,前方的路坎坷又长

6. zip, 没有其他提示了,替换html,发现下载了channel.zip的文件,打开readme.txt,发现第一条提示类似前面的问题,又得到collect the comments,修改了re部分,发现没结果,后来百度才知道是有关zipfile这个module的。实现也不是很难:

 import re
 import os
 import zipfile

 def find_next():
     comments = []
     prefix = '
     suffix = '.txt'
     pattern = re.compile(r'\D+(\d+)')
     z = zipfile.ZipFile('/home/zhangqi/channel.zip', mode='r')
     while True:
         try:
             filename = 'channel/' + prefix + suffix
             text = open(filename).read()
             prefix = pattern.findall(text)[0]
             print prefix
             comments.append(z.getinfo(prefix + suffix).comment)

         except Exception, e:
             print e
             break

     print ''.join(comments)

 find_next()
 #it's in the air. look at the letters.

最后看组成hockey的字母,连环trick有木有!

stay tuned...

Python Challenge的更多相关文章

  1. python challenge第1关--NoteBook上的“乱码”

    在 python challenge第0关中已经得到第1关的地址了: http://www.pythonchallenge.com/pc/def/map.html 一.观察地址栏和标签: What a ...

  2. Python Challenge 过关心得(0)

    最近开始用Openerp进行开发,在python语言本身上并没有什么太大的进展,于是决定利用空闲时间做一点python练习. 最终找到了这款叫做Python Challenge(http://www. ...

  3. Python Challenge 第四题

    这一题没有显示提示语,仅仅有一幅图片,图片也看不出什么名堂,于是直接查看源代码,源代码例如以下: <html> <head> <title>follow the c ...

  4. The Python Challenge 谜题全解(持续更新)

    Python Challenge(0-2) The Python Challengehttp://www.pythonchallenge.com/ 是个很有意思的网站,可以磨练使用python的技巧, ...

  5. The Python Challenge 0-4

    The Python Challenge 0-4 项目地址:http://www.pythonchallenge.com/ Level-0 提示Hint: try to change the URL ...

  6. python challenge答案参考

    Solutions to python challenge. http://garethrees.org/2007/05/07/python-challenge/ https://github.com ...

  7. Python Challenge 第一关

    偶然在网上看到这个,PYTHON CHALLENGE,利用Python语言闯关,觉得挺有意思,就记录一下. 第0关应该算个入口吧,试了好几次才试出来,没什么代码就不写了.计算一个结果出来就行. 第一关 ...

  8. The Python Challenge 闯关笔记

    The Python Challenge : http://www.pythonchallenge.com/ Level 0: 看提示图片中为2**38,计算值为274877906944. Hint: ...

  9. Python Challenge 过关心得(1)

    正式开始第1关,这一关的URL的特殊部分是map. 这关的图片上有一个本子,上面写着K→M,O→Q,E→G,稍微思索就能发现这几个字母都是按照字母表的顺序向后移动了两位,那么最投机取巧的方法就是把ma ...

随机推荐

  1. URI--http://zh.wikipedia.org/wiki/%E7%BB%9F%E4%B8%80%E8%B5%84%E6%BA%90%E6%A0%87%E5%BF%97%E7%AC%A6

    维基百科,自由的百科全书     在电脑术语中,统一资源标识符(Uniform Resource Identifier,或URI)是一个用于标识某一互联网资源名称的字符串. 该种标识允许用户对网络中( ...

  2. c# 调用EXCEL在VS上能正常运行,部署在IIS上不能实现,在VS中运行页面和发布之后在IIS中运行的区别

    发现一篇文章,很好,解决了这个问题:感谢原博主!特此做个笔记. 地址:http://www.cnblogs.com/zhongxinWang/p/3275154.html 发布在IIS上的Web程序, ...

  3. RTMP流媒体播放过程(转)

    http://blog.csdn.net/leixiaohua1020/article/details/11704355 本文描述了从打开一个RTMP流媒体到视音频数据开始播放的全过程. 注意:RTM ...

  4. 自写AES加密解密工具类

    此类主要用于加密与解密,采用128位ECB模式,PKCS5Padding填充补位. 可使用方法为加密返回二进制encryptBin(content, key).加密返回十六进制encryptHex(c ...

  5. MYSQL select ....outfile.....from.....

    select .... outfile  'file_path' fields terminate by '\t' lines terminate by '\r\n' from table_name; ...

  6. COB Epoxy灌膠時氣泡產生的原因與解決方法

    COB的黑膠 (Epoxy)有氣泡通常是不被允許的,因為外部氣孔不但會影響到外觀,內部氣孔更有可能會破壞 Wire bonding 的鋁線穩定度.既使在COB製程剛完成的時候沒有通過功能測試,也不代表 ...

  7. 重写 libev 的 EV_WIN32_HANDLE_TO_FD

    libev 的 EV_WIN32_HANDLE_TO_FD 默认实现是调用C库的  _open_osfhandle ,但这里有个问题是转换后,关闭 fd 就默认关闭了 handle.当它遇到 libc ...

  8. 从ora10g 刷数据到 8I基本操作步骤

    从ora10g 刷数据到 8I基本操作步骤 master :oracle 10g snapshot site: oralce 8i 在oracle 8i 中物化视图称为快照,oracle 8i建快照的 ...

  9. Python学习入门基础教程(learning Python)--5 Python文件处理

    本节主要讨论Python下的文件操作技术. 首先,要明白为何要学习或者说关系文件操作这件事?其实道理很简单,Python程序运行时,数据是存放在RAM里的,当Python程序运行结束后数据从RAM被清 ...

  10. MD5和SHA512Managed ——哈希算法

    本文来自:http://www.cnblogs.com/chuncn/archive/2008/02/26/1082418.html C#的哈希 哈希算法是啥?哈希英文hash,是一种数学算法,它能把 ...