0. 2的38次方

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

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

  1. import string
  2.  
  3. intab = string.ascii_lowercase
  4. outtab = intab[2:] + intab[:2]
  5. trans_table = string.maketrans(intab, outtab)
  6.  
  7. s = """
  8. g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle
  9. gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle.
  10. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."""
  11.  
  12. print s.translate(trans_table)
  13. print 'map'.translate(trans_table)
  14.  
  15. ##The result is
  16. ##
  17. ## i hope you didnt translate it by hand. thats what computers are for. doing
  18. ## it in by hand is inefficient and that's why this text is so long.
  19. ## using string.maketrans() is recommended. now apply on the url.
  20. ##ocr
  21.  
  22. ##apply ocr to the url

2. 寻找出现次数少的character

  1. import string
  2.  
  3. result = {}
  4. text = open('003help.txt').read()
  5. for ch in text:
  6. result[ch] = result.get(ch, 0) + 1
  7.  
  8. print result
  9. print ''.join(ch for ch in result if result[ch]==1)
  10. s = []
  11. for i in text:
  12. if i in string.ascii_lowercase:
  13. s.append(i)
  14. print ''.join(s)
  15.  
  16. ##apply 'equality' to the url

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

  1. import re
  2.  
  3. pattern = re.compile('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]')
  4. text = open('004help.txt').read()
  5.  
  6. t = re.findall(pattern, text)
  7. print ''.join(t)
  8.  
  9. ##apply to the url

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

  1. import re
  2. import urllib
  3.  
  4. url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
  5. nothing = '
  6. pattern = re.compile(r'and the next nothing is (\d+)')
  7. for i in range(400):
  8. try:
  9. text = urllib.urlopen(url+nothing).read()
  10. nothing = pattern.findall(text)[0]
  11. print nothing
  12. except Exception, e:
  13. print e
  14. break
  15. 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.

  1. #cPickle是c语言实现的pickle模块
  2. import cPickle as pickle
  3.  
  4. t = open('banner.p').read()
  5. s = pickle.loads(t)
  6. print s

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

  1. for line in s:
  2. 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的。实现也不是很难:

  1. import re
  2. import os
  3. import zipfile
  4.  
  5. def find_next():
  6. comments = []
  7. prefix = '
  8. suffix = '.txt'
  9. pattern = re.compile(r'\D+(\d+)')
  10. z = zipfile.ZipFile('/home/zhangqi/channel.zip', mode='r')
  11. while True:
  12. try:
  13. filename = 'channel/' + prefix + suffix
  14. text = open(filename).read()
  15. prefix = pattern.findall(text)[0]
  16. print prefix
  17. comments.append(z.getinfo(prefix + suffix).comment)
  18.  
  19. except Exception, e:
  20. print e
  21. break
  22.  
  23. print ''.join(comments)
  24.  
  25. find_next()
  26. #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. CSS基础要点概况

    1.CSS概述 1)css指层叠样式表 2)样式定义如何显示HTML元素 3)样式通常存储在样式表中 4)把样式添加到HTML4.0中,是为了解决内容与表现分离的问题 5)外部样式表可以极大提高工作效 ...

  2. Android中进程生命周期的优先级

    “我们不是生产者,我只是大自然的搬运工.” 学习Android最好的途径当然是强大的官方文档了,其中在Processes and Threads一节中对于进程生命周期淘汰优先级,有着详细的介绍.原文如 ...

  3. Oracle中中文、数字,英文混杂形式的字段进行排序的方法

    http://blog.csdn.net/p451933505/article/details/9272257 对Oracle中中文.数字.英文混杂形式的字段进行排序的方法: 例如: order by ...

  4. iOS学习笔记-死锁deadlock理解

    1.首先看一下官方文档的解释,这个block的队列是同步执行的,不像异步,这个方法直到block执行完毕才会返回 2.主线程一旦开启,就要先把自己的代码执行完成之后,才去执行加入到主队列中的任务 De ...

  5. C#操作注册表——读、写、删除、判断等基本操作

    一.引入命名空间: using Microsoft.Win32; 二.创建注册表项:CreateSubKey(name)方法 添加SubKey时候首先要打开一个表项,并设置参数为true,才能成功创建 ...

  6. 学习asp.net比较完整的流程

    如果你已经有较多的面向对象开发经验,跳过以下这两步: 第一步 掌握一门.NET面向对象语言,C#或VB.NET 我强烈反对在没系统学过一门面向对象(OO)语言的前提下去学ASP.NET. ASP.NE ...

  7. 使用ICE进程间通信时,IP和端口的选择

    使用ICE进程间通信时,IP和端口的选择 服务器在创建时使用的Endpint格式为 tcp  -h IP地址 -p 端口 1.IP地址的选择 如果填某个网卡的地址,则只在这个地址上监听,客户端必须连这 ...

  8. Shell学习之Shift的用法

        位置参数可以用shift命令左移.比如shift 3表示原来的$4现在变成$1,原来的$5现在变成$2等等,原来的$1.$2.$3丢弃,$0不移动.不带参数的shift命令相当于shift 1 ...

  9. Ubuntu Server 安装部署 Cacti 服务器监控

    本文的英文版本链接是 http://xuri.me/2013/10/20/install-the-cacti-server-monitor-on-ubuntu-server.html Cacti是一套 ...

  10. Android PorterDuff.Mode

    1.PorterDuff.Mode.CLEAR所绘制不会提交到画布上. 2.PorterDuff.Mode.SRC显示上层绘制图片 3.PorterDuff.Mode.DST显示下层绘制图片 4.Po ...