Python challenge 全部题解

Python Challenge

http://www.pythonchallenge.com/

http://garethrees.org/2007/05/07/python-challenge/

http://holger.thoelking.name/python-challenge/17

第一关

>>> 2 ** 38
274877906944L

输入274877906944.html

第二关

亮点:lowercase,maketrans

from string import lowercase,maketrans
text="""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."""
alph_mp=maketrans(lowercase,lowercase[2:]+lowercase[:2])
print text.translate(alph_mp)

第三关

亮点:with ''.join

with open('ocr.html','r') as fp:
    text=fp.read()
    ans=''
    for c in text:
        if c.isalpha():
            ans+=c
print ans
with open('ocr.html','r') as fp:
    text = fp.read()
    print(''.join([c for c in text if c.isalpha()]))
import re  
with open('ocr.html','r') as fp:
    text = fp.read()
    print (''.join(re.findall(r'[a-z]+', text))  )
import re  
with open('ocr.html','r') as fp:
    text = fp.read()
    print(re.sub(r'[^a-z]+', '',text))

第四关

import re
with open('1.txt','r') as fp:
    text = fp.read()
    print ''.join(re.findall(r'[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]',text))

第五关

import urllib
import re
 
ending = "8022"
 
while True:
    url=ending
    pagesource = urllib.urlopen("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=" + ending)
    text = pagesource.read()
    number = re.findall(r'\D+(\d+$)', text)
    ending = "".join(number)
    if ending == "":
        print url,text
        break

第六关

import pickle
import sys
sys.stdout=open("out.txt","w")
with open('banner.p','rb') as fp:
    t = pickle.load(fp)
    for item in t:
        print(''.join([x[0] * x[1] for x in item]))

第七关

import re  
import zipfile  

zf = zipfile.ZipFile('channel.zip')  
zc=[]  
name = '90052.txt'  
while True:  
    zinfo = zf.getinfo(name)  
    z = zf.open(name)  
    data = re.findall(r'\d+$',z.read())
    z.close()  
    zc.append(zinfo.comment)  
    if data:  
        name = '%s.txt' % data[0]  
    else:  
        break  
print ''.join(zc)  

name = '90052.txt'
while True:
    f = open('channel/%s' % name)
    text=f.read()
    print text
    data = text.split()[-1]
    f.close()
    if data.isdigit():
        name = '%s.txt' % data
    else:
        print text 
        break

第八关

from PIL import Image  
import re  
im = Image.open('oxygen.png')  
msg = ''.join([chr(im.getpixel((i, 43))[0]) for i in xrange(0, 609, 7)])  
print ''.join([chr(int(x)) for x in re.findall(r'\d{3}',msg)]) 

第九关

import bz2
un=b'BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
pw=b'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'
username = bz2.decompress(un)
password = bz2.decompress(pw)
print(username,password)

第十关

from PIL import Image,ImageDraw
im = Image.open("good.jpg")

first_set = [146,399,163,403,170,393,169,391,166,386,170,381,170,371,170,355,169,346,167,335,170,329,170,320,170,
310,171,301,173,290,178,289,182,287,188,286,190,286,192,291,194,296,195,305,194,307,191,312,190,316,
190,321,192,331,193,338,196,341,197,346,199,352,198,360,197,366,197,373,196,380,197,383,196,387,192,
389,191,392,190,396,189,400,194,401,201,402,208,403,213,402,216,401,219,397,219,393,216,390,215,385,
215,379,213,373,213,365,212,360,210,353,210,347,212,338,213,329,214,319,215,311,215,306,216,296,218,
290,221,283,225,282,233,284,238,287,243,290,250,291,255,294,261,293,265,291,271,291,273,289,278,287,
279,285,281,280,284,278,284,276,287,277,289,283,291,286,294,291,296,295,299,300,301,304,304,320,305,
327,306,332,307,341,306,349,303,354,301,364,301,371,297,375,292,384,291,386,302,393,324,391,333,387,
328,375,329,367,329,353,330,341,331,328,336,319,338,310,341,304,341,285,341,278,343,269,344,262,346,
259,346,251,349,259,349,264,349,273,349,280,349,288,349,295,349,298,354,293,356,286,354,279,352,268,
352,257,351,249,350,234,351,211,352,197,354,185,353,171,351,154,348,147,342,137,339,132,330,122,327,
120,314,116,304,117,293,118,284,118,281,122,275,128,265,129,257,131,244,133,239,134,228,136,221,137,
214,138,209,135,201,132,192,130,184,131,175,129,170,131,159,134,157,134,160,130,170,125,176,114,176,
102,173,103,172,108,171,111,163,115,156,116,149,117,142,116,136,115,129,115,124,115,120,115,115,117,
113,120,109,122,102,122,100,121,95,121,89,115,87,110,82,109,84,118,89,123,93,129,100,130,108,132,110,
133,110,136,107,138,105,140,95,138,86,141,79,149,77,155,81,162,90,165,97,167,99,171,109,171,107,161,
111,156,113,170,115,185,118,208,117,223,121,239,128,251,133,259,136,266,139,276,143,290,148,310,151,
332,155,348,156,353,153,366,149,379,147,394,146,399]

second_set = [156,141,165,135,169,131,176,130,187,134,191,140,191,146,186,150,179,155,175,157,168,157,163,157,159,
157,158,164,159,175,159,181,157,191,154,197,153,205,153,210,152,212,147,215,146,218,143,220,132,220,
125,217,119,209,116,196,115,185,114,172,114,167,112,161,109,165,107,170,99,171,97,167,89,164,81,162,
77,155,81,148,87,140,96,138,105,141,110,136,111,126,113,129,118,117,128,114,137,115,146,114,155,115,
158,121,157,128,156,134,157,136,156,136]

nim = Image.new(im.mode, im.size)  
draw = ImageDraw.Draw(nim)
draw.line(first_set, fill='#fff')
draw.line(second_set, fill='#fff')
del draw
nim.save('result.png')

第十一关

import re
def describe(s):
    return "".join([str(len(m.group(0))) + m.group(1) for m in re.finditer(r"(\d)\1*", s)])
s = "1"
for dummy in range(30):
    s = describe(s)
print len(s)  # prints 5808

第十二关

import re
def describe(s):
    sets = re.findall("(1+|2+|3+)", s)  # like "111", "2", ...
    return "".join([str(len(x))+x[0] for x in sets])
s = "1"
for dummy in range(30):
    s = describe(s)
print len(s)  # prints 5808

第十三关

from PIL import Image,ImageDraw
new_img = Image.new('RGB', (320, 240))
img = Image.open('cave.jpg')
for x in range(0,640,2):
    for y in range(0,480,2):
            pixel = img.getpixel((x, y))
            new_img.putpixel((x//2, y//2), pixel)
new_img.show()

第十四关

f = open('evil2.gfx','rb')
content = f.read()
f.close()

for i in xrange(5):
    f = open('%d.jpg' % i, 'wb')
    f.write(content[i::5])
    f.close()

第十五关

import xmlrpclib
xmlrpc = xmlrpclib.ServerProxy("http://www.pythonchallenge.com/pc/phonebook.php")
print xmlrpc.system.listMethods()
print xmlrpc.system.methodHelp('phone')
print xmlrpc.phone('Bert')

第十六关

from PIL import Image
strip = Image.open('wire.png')
spiral = Image.new(strip.mode, (100,100), 0)
dirs = [(1,0),(0,1),(-1,0),(0,-1)]
x,y,z = -1,0,0
for i in range(200):
    d = dirs[i % 4]
    for j in range(100 - (i + 1) // 2):
        x += d[0]
        y += d[1]
        spiral.putpixel((x,y), strip.getpixel((z,0)))
        z += 1
spiral.save('spiral.png')

第十七关

import datetime
for year in range(1996,1582,-20):
    if datetime.date(year, 1, 1).weekday() == 3:  
        print year,

第十八关

from PIL import Image, ImageChops
image = Image.open("mozart.gif")
magic = chr(195)
for y in range(image.size[1]):
    box = 0, y, image.size[0], y + 1
    row = image.crop(box)
    bytes = row.tostring()
    i = bytes.index(magic)
    row = ImageChops.offset(row, -i)
    image.paste(row, box)
image.save("new.gif")

第十九关

#http://www.pythonchallenge.com/pc/return/romance.html
import urllib2
from urllib import quote_plus, unquote_plus
import cookielib
import re
print "Staring to follow the busynothing chain, but also picking up the crumbs!"
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj),urllib2.HTTPHandler())
def getPage(nothing="12345"):
	url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing="
	req = urllib2.Request(url+nothing)
	response = opener.open(req)
	return response.read()
pat = re.compile(r"(.*?)and the next busynothing is (\d*)$")
num = 12345
cookievals = []
count = 0
while True:
	count += 1
	m = pat.match(getPage(str(num)))
	for cookie in cj:
			cookievals.append(unquote_plus(cookie.value))
	if m == None:
		break
	elif count > 400:
		print "400 times is more than enough"
		break
	else:
		print str(count) + ": " + m.group(0)
		num = int(m.group(2))
print "Done retrieving cookies"
print
print "Decompressing the message"
import bz2
message = bz2.decompress("".join(cookievals))
print "The message is: %s" % message
print
print "Mozart was born to Leopold..."
print "Looking up Leopold"
##Call his father Leopold
import xmlrpclib
x= xmlrpclib.ServerProxy("http://www.pythonchallenge.com/pc/phonebook.php")
number = x.phone("Leopold")
print "Leopold's number is: %s" % number 
print
print "Calling Leopold and sending him the mssage"
o = urllib2.build_opener()
message = "the flowers are on their way"
o.addheaders.append(('Cookie', 'info='+quote_plus(message)))
res = o.open("http://www.pythonchallenge.com/pc/stuff/violin.php")
print "Message sent!"
print
print"His response is..."
print res.read()


0


http://www.pythonchallenge.com/pc/def/0.html

2的38次幂 = 274877906944,进入下一关
1

http://www.pythonchallenge.com/pc/def/274877906944.html

http://www.pythonchallenge.com/pc/def/map.html

有图上的3行提示,看出规律是右移2次。将一大段文本解密后告诉我们用同样的方法处理url。

即然map->ocr。
2

http://www.pythonchallenge.com/pc/def/ocr.html

提示看源文件,一大堆乱字符,统计最少的字符。

结果为equality。
3

http://www.pythonchallenge.com/pc/def/equality.html

根据提示,找寻的是这样的一些小写字母:他的左右各有三个大写字母包围着。

答案是linkedlist。
4

http://www.pythonchallenge.com/pc/def/linkedlist.html

http://www.pythonchallenge.com/pc/def/linkedlist.php

点击网页上的图片之后,进入连接

http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345

提示and the next nothing is 92512,然后就把12345改成92512;他又提示and the next nothing is 64505……

意图很明显了,写个程序自动化如上动作。
5

http://www.pythonchallenge.com/pc/def/peak.html

peak hell说要读出来,跟pickle的音很相似吧!banner.p是pickle.loads()的数据来源。loads()反序列化来的数据是二重序列,就是那种常见的纯文本来勾勒出图形的风格。

答案是channel。
6

http://www.pythonchallenge.com/pc/def/channel.html

拉链(zip)安之zip压缩格式。下载channel.zip,然后写个程序提取注释什么的(看了官方的答案才明白,没用过zip库真不知道这么处理。。。)。

答案是oxygen。
7

http://www.pythonchallenge.com/pc/def/oxygen.html

图片上的那条灰度条很可疑。最终是按照ASCII解码出来得到答案。我是官方解答的。。

答案是integrity

PS: Python没有内置图像处理库,推荐PI。
8

http://www.pythonchallenge.com/pc/def/integrity.html

看源文件,最后的un和pw分别是用户名和密码的bz2加密。

解密后为huge和file。
9

http://www.pythonchallenge.com/pc/return/good.html

提示:connect the dots

源文件里的first,second分别是两堆x和y的坐标,连起来以后first是一头牛,second是牛头。

如果才cow,提示说是公的。。。

答案是bull。
10

http://www.pythonchallenge.com/pc/return/bull.html

http://www.pythonchallenge.com/pc/return/sequence.txt

a = [1, 11, 21, 1211, 111221,

len(a[30]) = ?

是不是感觉到了小学数奥和考公的意味儿~

官方的规律是这样的:

1

1个1,写作11

2个1,写作21

1个2,1个1,写作1211

……

答案是5808
11

http://www.pythonchallenge.com/pc/return/5808.html

图片看起来像叠起来的,结合提示odd even,将此图提取为四张图:分别为奇奇,偶偶,奇偶,偶奇的像素。

看到某图中有上角的evil字样了吗?
12

http://www.pythonchallenge.com/pc/return/evil.html

看源文件,图片名是evil1.jpg。

试试evil2.jpg,提示不是jpg是gfx,下载此文件。不知道做什么了。

试试evil3.jpg说是no more evil;不信,试试evil4.jpg,图片显示错误,其实它是文本文件,“Bert is evil”,下一题的提示。

看官方答案,图中那人把扑克牌分为5堆,提示把gfx文件分成5个文件,当然是按发牌的方式。。。

最后是5个图片,将图中的字母连起来得到disproportional
13

http://www.pythonchallenge.com/pc/return/disproportional.html

call the evil,点击图片上的“5”,到达

http://www.pythonchallenge.com/pc/phonebook.php

竟然能从disproportional.html源文件里的remote字样猜到Remote Procedure Call(RPC)。。。

此RPC服务提供了一个“phone()”方法,还记得Bert is evil吗?

返回555-ITALY
14

http://www.pythonchallenge.com/pc/return/italy.html

网页源码提示:100*100 = (100+99+99+98) + (...

把下面的小图按提示展开,得到一只猫。

使用cat,提示是uzi。
15

http://www.pythonchallenge.com/pc/return/uzi.html

由右下角2月有29天确定是闰年,1XX6年是闰年,且结合源码中提示是第二年轻的,得知是1756年。

源码提示明天给他买花,得知是1756-01-27。百度or谷歌之,莫扎特。

答案mozart
16

http://www.pythonchallenge.com/pc/return/mozart.html

对齐品红色的线段。这是gif图片,品红色在调色板里对应195。

调整后的图片显示答案romance
17

http://www.pythonchallenge.com/pc/return/mozart.html

第四关的图片 + cookies = 查看第四关的cookies

第四关:http://www.pythonchallenge.com/pc/def/linkedlist.php

查看其cookies看到info = you+should+have+followed+busynothing...

从http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing=12345一路跟下去, 收集cookies里info的内容,得到BZh9.....这是bz2格式的数据,用bz2.decompress()解压得到如下提示

is it the 26th already? call his father and inform him that "the flowers are on their way". he'll understand.

Mozart's 的父亲是 Leopold,通过XML-RPC得到他的电话是555-VIOLIN。去violin.html得到提示no! i mean yes! but ../stuff/violin.php.

去http://www.pythonchallenge.com/pc/stuff/violin.php 告诉他"the flowers are on their way"(设置cookies中的info为此字符串)。

响应页面有句h well, don't you dare to forget the balloons.
18

http://www.pythonchallenge.com/pc/return/balloons.html

找茬?别上当,是brightness!进入brightness.html,源码提示deltas.gz

解压后是个文本文件,十六进制的字符串,左右两大块(记事本不能执行换行符)。可以发现两块开头是 相同的(是png文件头),后面又有不同。结合"deltas"的意思,通过求最大公共子序,及左右两块分别 减去这个子序留下的内容,得到三个图片。一个图为下一关答案,另两个图为用户名和密码,后面关卡用的。

python内置了difflib库,方便的比较文本。

知识加油站:有两个字符串: a = "abcdefgh",b = "123bcde4fhg5", a和b的最大公共子序(顺序但 可不连续)为"bcdef",最大公共子串为"bcde"(顺序并连续)。

用户butter密码fly
19

http://www.pythonchallenge.com/pc/hex/bin.html

查看源文件,是一封email。附件是个wave音频(indian.wav),听到"sorry"。去sorry.html提示- "what are you apologizing for?"。

将音频文件高地位调换,得到另一个音频文件(endian.wav),听到"you are an idiot, aaaaaa~"。

答案idiot
20

http://www.pythonchallenge.com/pc/hex/idiot.html

http://www.pythonchallenge.com/pc/hex/idiot2.html

图片说“私人财产,走远!”,下面位子又贱贱的让你小心刺探。。。发现图片的headers里响应 部分Content-Range: bytes 0-30202/2123456789(Chrome里只需按F12然后Networks里就可以方便地 查看headers)。原来只是返回了整个文件的前面一小段。

Range从30203开始发送请求,如此反复从上一个响应Content-Range的末尾接着新的请求,有如下返回:

Why don't you respect my privacy?

we can go on in this way for really long time.

stop this!

invader! invader!

ok, invader. you are inside now.

去invader.html,提示"Yes! that's you!"

瞎试探,试着请求从2123456789开始的Range,返回:

"esrever ni emankcin wen ruoy si drowssap eht",倒过来"the password is your new nickname in reverse"

即invader倒过来 = redavni

从后往前刺探刺探,在2123456743处得到提示”and it is hiding at 1152983631“,这个位置藏着个Zip文件。

保存下来,用密码redavni解压,readme说这就是21关了!
21

package.pack是个多重压缩的东东。readme里两句提示:

We used to play this game when we were kids -- 老外小时候玩的游戏,文化的差别。

When I had no idea what to do, I looked backwards -- 适时逆序下

总之尝试zlib、bz2和逆序这三种操作,最后用这些操作序列对应空白、某符号和换行描出结果。

答案cooper
22

http://www.pythonchallenge.com/pc/hex/copper.html

别忘了用户是butter密码是fly

源码提示 or maybe white.gif would be more bright

gif图片很容易想多多帧的,ImageSequence.Iterator(Image.open("white.gif"))得知133帧。

使用现代图像处理工具可以方便的查看每一帧的信息,可以发现每一帧上都有一个比其它点更黑的点。

把这些点的坐标找出来,最后描出结果。

答案bonus
23

http://www.pythonchallenge.com/pc/hex/bonus.html

源码提示:what is this module? 无语,import this竟然会是一段文本,python的哲学。。

源码提示2:va gur snpr bs jung? 利用this模块this.d.get()解码,翻译过来 in the face of what?

The Zen of Python, by Tim Peters

[...] In the face of ambiguity, refuse the temptation to guess. [...]

答案ambiguity
24

http://www.pythonchallenge.com/pc/hex/ambiguity.html

哟哟切克闹,迷宫!迷宫的入口与出口是在右上角与左下角。

解这个迷宫,得到一个zip压缩文件。其中又长图片。

答案lake
25

http://www.pythonchallenge.com/pc/hex/lake.html

看网页源码,lake1.png附近有提示“can you see the waves?”。

不是图片中的波纹,而是lake1.wav ~ lake25.wav的声音文件。。。

用wave.open('lake1.wav','r').getnframes()返回是10800

每个碎片含有3600个像素的数据,将这25个碎片按5x5拼成一张图。

答案decent

0

http://www.pythonchallenge.com/pc/def/0.html

猜238,说是38在2上面一点点,猜238= 274877906944,进入下一关

1

http://www.pythonchallenge.com/pc/def/274877906944.html

http://www.pythonchallenge.com/pc/def/map.html

根据图上的提示,是位移加密,每个字符位移两次,把下面那些提示用这个方法的处理,告诉我用同样的方法处理url,得到ocr

2

http://www.pythonchallenge.com/pc/def/ocr.html

提示看源文件,一大堆字符,说要找到出现次数最少的字符,发现是equality

3

http://www.pythonchallenge.com/pc/def/equality.html

一个小写字母,每边刚好有三个大写字母做保镖。

XXX

XxX

XXX

 

   X

   X

XXXxXXX

   X

   X

 

xXXXxXXXx 这个才是对的……

找到的答案是linkedlist

4

http://www.pythonchallenge.com/pc/def/linkedlist.html

http://www.pythonchallenge.com/pc/def/linkedlist.php

点击网页上的图片之后,进入连接

http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345

提示and the next nothing is 92512

然后就把12345改成92512,他又提示and the next nothing is 64505……

就这么一路下去,照着提示,几百次之后就行了……

5

http://www.pythonchallenge.com/pc/def/peak.html

peak hell说要读出来,pickle

下载banner.p

然后就又不会了……

6

http://www.pythonchallenge.com/pc/def/channel.html

从图片看出,拉链(zip)是主角……

下载channel.zip

然后和第4关差不多,做个程序一路走下去。

然后据说有注释,但是我找不到……

7

http://www.pythonchallenge.com/pc/def/oxygen.html

图片上的那条灰度按照ASCII解码出来后是integrity

8

http://www.pythonchallenge.com/pc/def/integrity.html

标题:working hard?

图片:一只蜜蜂

bee? busy. busy? busy too ? bz2?

下面的用户名和密码都是用bz2加密的,解密之后点图片的链接,然后进到下一关,输入用户名密码即可。

之后几关的用户名密码

huge

file

9

http://www.pythonchallenge.com/pc/return/good.html

提示:connect the dots

后面代码里的first,second分别是两堆x和y的坐标,连起来以后first像一头牛,second像是一个十字,难道是横过来的X,叫做牛X……试了下cow,提示说是公的,bull。从这张图看出来,发现second原来只是描了下牛的头……

10

http://www.pythonchallenge.com/pc/return/sequence.txt

a = [1, 11, 21, 1211, 111221,

len(a[30]) = ?

话说其实找到了个很诡异的规律,但是和官方的不一样。官方的规律是这样的:

1

1个1,写作11

2个1,写作21

1个2,1个1,写作1211

……

最后算一下就出来了5808

11

http://www.pythonchallenge.com/pc/return/5808.html

图片一眼可以看出用了IE浏览器选中图片的那种效果,加上odd even的提示,更确信是这个了。一张图什么都没,另一张图一看以为什么都没,结果居然是显示器的问题……另一个显示气能很明显看出一种血红色的恐怖的图样,右上写着evil字样。

12

http://www.pythonchallenge.com/pc/return/evil.html

一开始看着这么奇怪的图片,以为是图像处理的。看着图片叫evil1.jpg,感觉怪怪的,试了下evil2.jpg,还真有,提示说not jpg –gfx改成gfx真有这么个文件,不过不知道是什么东西。

evil3.jpg:no more evils…

evil4.jpg:Bert is evil! goback!

接下来就搞不懂怎么办了,看了提示才知道,原来原图那人把扑克牌分成5堆,提示着要把那个gfx文件用分牌的方式分成5个文件,结果图片的内容连起来就是下一关的网站了。

13

http://www.pythonchallenge.com/pc/return/disproportional.html

按下数字键5之后会进入http://www.pythonchallenge.com/pc/phonebook.php

他说要打电话给一个evil的人,之前有提到Bert is evil,那就给他打电话吧……据说这个页面用了Remote Procedure Call (RPC)这种神奇的协议,反正照着一个例程改了下他就返回了555-ITALY

14

http://www.pythonchallenge.com/pc/return/italy.html

根据网页标题的提示:walk around

网页代码的提示:100*100 = (100+99+99+98) + (...

还有那张螺旋状的面包图片,猜测,要把下面那张图(其实这个图是10000*1的,居然能显示成方的)以这种形式展开,结果出现一只猫。

在此之前有个小插曲,如果把那个图以一行行的形式展开会出现bit字样,然后进bit.html会提示说你走错路了……

然后输入cat.html,提示and its name is uzi. you'll hear from him later.

15

http://www.pythonchallenge.com/pc/return/uzi.html

一张日历,1xx6年,根据星期和右下角显示的很小的二月份的29天,可以猜出是闰年,并且把答案缩小在:

这些年份中

1176

1356

1576

1756

1976

buy flowers for tomorrow,图上标了1.26,说明1.27有事发生

he ain't the youngest, he is the second

从上面这些年份中1976是最年轻的,第二年轻的是1756

2002年1月27日 尼日利亚首都拉各斯大爆炸2000人丧生

1999年1月27日 广西巨贪李乘龙一审被判处死刑

1998年1月27日 中国民乐除夕回荡维也纳(这是中国民族音乐历史上第一次在有“音乐圣殿”之称的金色大厅展现风采)

1997年1月27日 美科学家制造出原子激光

1982年1月27日 瓦尔德海姆获“联合国和平奖”

1973年1月27日 越美签定关于越南问题的巴黎协定

1964年1月27日 我国与法国建交

1950年1月27日 我国建立统一税收制度

1945年1月27日 苏军解放奥斯威辛集中营

1937年1月27日 美国遭受严重水灾,100万人无家可归

1926年1月27日 电视诞生

1901年1月27日 意大利作曲家威尔第逝世

1893年1月27日 宋庆龄诞辰

1822年1月27日 文明古国希腊独立

1756年1月27日奥地利音乐大师莫扎特诞生

1142年1月27日 岳飞被害

mozart

16

http://www.pythonchallenge.com/pc/return/mozart.html

提示说把它弄直,图片里面杂乱无章的点很明显有很多是品红色的短线,把图按行平移,使得红线对齐,出现了romance字样。

17

http://www.pythonchallenge.com/pc/return/romance.html

小牛做的,等他补解题报告

这个……我忘了,过程相当复杂,还是看国外的攻略吧。

18

http://www.pythonchallenge.com/pc/return/balloons.html

提示说两张图片有什么不同,然后提示说区别比我们想的要简单,那就是亮度

http://www.pythonchallenge.com/pc/return/brightness.html

图片一样,源码里面提示下载deltas.gz

下载一看是个文本文件很明显分成了左右两块,写成了十六进制的形式,16个一行,然后按行求出了左右两边的最长公共子序列,并且左右分别减去这个LCS,得到三个png文件,一个写了http://www.pythonchallenge.com/pc/hex/bin.html

一个是butter

一个是fly

其中有一张图片需要用ps打开才行,浪费好多时间……

之后几关的用户名密码

butter

fly

19

http://www.pythonchallenge.com/pc/hex/bin.html

一个电子邮件,下载后能弄出音乐,听到sorry。

图中显示的印度地图颜色是反的,联想到反转。

除了文件头之外的都前后字节交换,从新的音乐听到idiot,然后过去……

好神奇,居然正反都有能听的声音……

20

http://www.pythonchallenge.com/pc/hex/idiot.html

http://www.pythonchallenge.com/pc/hex/idiot2.html

从图片的包头中看到range,然后编程构造请求的range,大概这样

 

var req =WebRequest.Create(@"http://www.pythonchallenge.com/pc/hex/unreal.jpg")as HttpWebRequest;

req.AddRange(r, r + len);

req.Credentials = newNetworkCredential("butter", "fly");

var rep = req.GetResponse();

using (var sr = rep.GetResponseStream())

{

   StreamWriter s = new StreamWriter("c:\\1.dat");

   byte[] a = new byte[10000000];

   int t;

   while ((t = sr.Read(a, 0, a.Length)) != 0)

    {

       // int t = sr.BaseStream.Read(a, 0, a.Length);

       s.BaseStream.Write(a, 0, t);

    }

   //Console.WriteLine("{0} {1}",r,sw.ReadToEnd());

   s.Close();

}

先是一大堆文字提示,说我入侵,然后尝试着把range的开始位置设置为2123456789,提示了密码是我的新昵称,还提示了结果所在的位置,然后在那个位置做完range的头,下载,发现一个压缩包,密码是redavni

21

这关没实现,直接看网上的答案了。

大概的意思是,刚才下载到的那个压缩包里面有个package.pack文件,其实是个压缩文件,使用了zlib和bz2两种方式压缩,到时候还要适当地把文件逆序一下(关于这个的提示是他说这是个小时候的游戏,击鼓传花,国外的玩法不一样,需要一层层地拆传递的那个东西……)然后记录这三中东西的操作,一个记作“”,一个“#”,一个回车,就看到了用字符拼起来的copper字样。

22

http://www.pythonchallenge.com/pc/hex/copper.html

提示:模拟,又提示white.gif会比想象中的亮度更大,发现这个gif是多帧的,差不多在图像的正中间有比黑色稍微亮一点的颜色……那些颜色出现在小键盘一样布局的3*3的9个位置上。然后一次当作方向向量描点处理,弄出来刚好是bonus这几个字母

23

http://www.pythonchallenge.com/pc/hex/bonus.html

'va gur snpr bs jung?'

这个又是第1关中出现的位移加密……然后翻译过来就是in the face of what?

what is this module?

这个比较无语,在python里面输入 import this,显示了一大段:

The Zen of Python, by Tim Peters

 

Beautiful is better than ugly.

Explicit is better than implicit.

Simple is better than complex.

Complex is better than complicated.

Flat is better than nested.

Sparse is better than dense.

Readability counts.

Special cases aren't special enough tobreak the rules.

Although practicality beats purity.

Errors should never pass silently.

Unless explicitly silenced.

In the face of ambiguity, refuse thetemptation to guess.

There should be one-- and preferably onlyone --obvious way to do it.

Although that way may not be obvious atfirst unless you're Dutch.

Now is better than never.

Although never is often better than *right*now.

If the implementation is hard to explain,it's a bad idea.

If the implementation is easy to explain,it may be a good idea.

Namespaces are one honking great idea --let's do more of those!

然后下一关就是ambiguity……

24

http://www.pythonchallenge.com/pc/hex/ambiguity.html

bfs,从上到下,然后把路过的点的颜色(只看rgb中的r)全部间隔着写到一个文件中,发现是个zip,提示下一关lake

25

http://www.pythonchallenge.com/pc/hex/lake.html

lake1.wav ~lake25.wav 按照图像拼起来

26

http://www.pythonchallenge.com/pc/hex/decent.html

到19关那个地方写的邮件发道歉信过去

然后知道了之前21关那个压缩包里面的没用到的mybroken.zip的md5,还说错了一个字节,穷举一下,里面的图像里写着speed

下面提示要错过船了,speedboat

27

http://www.pythonchallenge.com/pc/hex/speedboat.html

看了网上的提示才过的……

一开始当然先下载zigzag.gif

甚至研究了GIF的文件格式,发现文件结构很诡异,没用GIF的标准来压缩。

貌似他的tables一个是颜色表,一个是下面的图像

图像的灰度当作二进制输出,图像灰度的索引也输出,发现这两个几乎是一样的,但是差一个字节。

对齐之后,发现两个文件只有一点点不同,把不同之处提取出来,其中有一个可以看出是BZ2压缩的,解压之后是个文本,里面貌似都是下一关的网址和关键字。

网上找了一份python关键字,把文件中的关键字全删掉之后,得到了:

../ring/bell.html

switch

repeat

这3个字符串的序列,用户名repeat,密码switch

之后几关的用户名密码

repeat

switch

28

http://www.pythonchallenge.com/pc/ring/bell.html

传说RING-RING-RING读着读着会变成green.

访问green.html会提示“yes! green!”

从图中也能看出很多绿色的竖条,提取绿通道之后发现那些竖条是成对的,偶数下标的和奇数下标的总是一个暗,一个亮。

网页标题也提示pairs,猜想两个一组。

组内求差之后发现差一般都是42或-42,只有180行头上有些不是,把那些的差值提前出来,是“whodunnit().split()[0] ?”

Python发明人Guido Van Rossum,结果就是guido

29

http://www.pythonchallenge.com/pc/ring/guido.html

网页的源文件后面有大量的空格……

然后把每行的空格数写到一个文件里,又是BZh开头的,直接解压。

Isn't it clear? I am yankeedoodle!

30

http://www.pythonchallenge.com/pc/ring/yankeedoodle.html

把csv文件下载下来之后是一大堆浮点数,转成音频听不出东西。

里面一共有7367个浮点数,7367=139*53,用浮点数*256当灰度画成139宽53高的图像。显示出了一个方程。

n=str(x[i])[5]

+str(x[i+1])[5]

+str(x[i+2])[6]

然后浮点数当字符串,3个一组,使用公式计算n,转ASCII看,发现提示下一关是grandpa

28关猜名字的时候只猜了grandfather,差点猜到了……

31

http://www.pythonchallenge.com/pc/ring/grandpa.html

先是要猜这块石头是什么地方的,找到是

Koh Samui

Thailand

然后用户名kohsamui,密码thailand,跳到下一个页面

之后几关的用户名密码

kohsamui

thailand

http://www.pythonchallenge.com/pc/rock/grandpa.html

不知道怎么猜到半径是2的,我是一点点试出来的。

画出自己的分形之后,和原图比较,发现新图和原图有些像素有不同。

不同的颜色的索引的差距都是16,有+16和-16。一共有1679处不同。

1679=23*73

于是根据差距的正负依次画出了这个图。

......*.*.*.*..........

..*.*.....*.*.......*..

*...*...*...*..*.**..*.

*.*.*.*.*.*.*.*..*..*..

.......................

............**.........

..........**.*.........

..........**.*.........

.........*.*.*.........

.........*****.........

.......................

**....***...**....**...

*.............**..*....

**.*...**...**....**.*.

*****.*****.*****.*****

.......................

...*.................*.

.......................

....*.................*

*****.............*****

.......................

**....**....***...**...

*.......*.........*....

**.*....**...***..**.*.

*****.*****.*****.*****

.......................

...*......**.........*.

..........**...........

....*.....**..........*

*****.....**......*****

..........**...........

..*........*........*..

...*......**.......*...

....**....**......*....

......**...*....**.....

..........**..**.......

......**...*....**.....

....**....**......*....

...*......*........*...

..*.......**........*..

.*........**........*..

.*.........*.......*...

..*.......*.......*....

...*............**.....

....**........**.......

..*...***.*.**.........

..*.......*............

..*.....*****..........

..*....*.***.*..*.**.**

......*..***..*..******

*.***....***.....**.***

.........*.*.....***.**

..*......*.*.....******

..*......*.*.....**....

..*.....**.**..........

.......................

..***.....*............

..***.*.*...*.*.*.*.*.*

..***.........*.*.*.*..

..............*.*......

........*****..........

......*********........

....***.......***......

...**...........**.....

..**.*.........*.**....

.**..**.......**..**...

.*...*.*.....*.*...*...

.*...*..*...*..*...*...

.....*...*.*...*.......

.....*....*....*.......

.....*.........*.......

.......*..*.*..........

.****..*****.*..****...

google找了好久……

Crop Circle

Chilbolton Radio Telescope

Wherwell, Hampshire, England

最后发现arecibo正是下一关的地址……

32

http://www.pythonchallenge.com/pc/rock/arecibo.html

一个很神奇的游戏。每个行列的开头写着该行/该列有几个连续区段,分别多长。

给出这些表头的数字,要求这个图案。

先手算得到warmup的结果是一个向上的箭头,up.html里面有一个超大的要解……

弄出来一条蟒蛇python.html

页面上有提示

"Free" as in "Freespeech", not as in "free

Google到gnu上的信息: Tounderstand the concept, you should think of free as in free speech, not as infree beer.

33

http://www.pythonchallenge.com/pc/rock/beer.html

代码中的图片为beer1,打开beer2.jpg,提示png

下载之后是个神奇的图片……

按照网页代码中那首诗的指导思想,要把图片中亮的点去掉,剩下的点数应该刚好是平方数,这样就能画在一张方的图里了。

测试发现图片中的颜色为1, 2, 7, 8, 13, 14都是成组出现的,这样就利用去掉比第一组亮的点,去掉比第二组亮的点……最后产生了33张图片。

其中均为字母,有些字母外面有框,连起来是 gremlins。

 

33关全结束了,很好很强大。







  • 1
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值