涉水The Python Challenge

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章