涉水The Python Challenge

来源:互联网 发布:数据透视表英文怎么说 编辑:程序博客网 时间:2024/05/16 12:36

在Stack Overflow 上看到学习Python 的一个方法是用Python 破解The Python Challenge。但我喜欢用Ruby,谁管得着呢^_^

the python challenge

0. 入门关很简单。

level 0

 

1. 破解一段话,观察图片很容易发现解码表把字母表循环右移两位。

level 1

 

译文: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.

再对url ("map")实施变换得"ocr"。

update: 发现String有个内置替换函数tr()。看,多简洁。

 

2. 查看网页源码,可以看到网页注释中有一堆乱码,上面有句话"find rare characters in the mess below:"(“找出稀少的字符”)。

level 2

想到用hash 来统计各个字符的出现次数,并记录首次出现的顺序。

 

你会得到"equality"。第三关,我来了!

3. 正则表达式。好吧,我承认,我是看了别人的解答。

level 3

打死我也想不出来数据在网页源码中(虽然上一题提醒过),而且还是用的正则表达式解。下面是Ruby 版。

 

4.还没想出来……

level 4