A year has passed since I visited Python Challenge the last time. And it’s not easy to start it again I’ve got a project that deals with Python image process, so I spend some time on the PIL handbook. And after that, I think trying this challenge is a good practice
However after […]
Well this is not an easy one.
The unpickling is as easy as it should:
import pickle
f = open(”banner.p”, “r”)
x = pickle.load(f)
But after that I was lost. x is a list of lists, with 23 items, each item are constructed with one or more tuples, each tuple has two elements: one ” ” or “#”, and one […]
Well first I need to figure out what to zip. I took a look at the HTML source again and found something unusual: the hint looks like:
<html> <!– <– zip –>
There’s an extra “<—” in the HTML comment. I believe this is pointing me what to zip. But after I tried zip “html”, “<html”, the […]
Following the idea yesterday, here is my first script:
import urllib;
import string;
import re;
def followNothing(url):
page=urllib.urlopen(url)
pagecontent = page.read()
print pagecontent
result =re.search(”[0-9]{5}”, pagecontent)
if result:
num = pagecontent[result.start():result.end()]
nexturl = “http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=” + num
followNothing(nexturl)
else:
print “fix the script!”
and I got:
In [12]: followNothing("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345")
and the next nothing is 92512
and the next nothing is 64505
<font color=red>Your hands are getting tired </font>and the next nothing is 50010
and the next […]
Well, it said EXACTLY three big bodyguard, so the first try is like this:
import re
target = re.compile(r”[!A-Z][A-Z]{3}([a-z])[A-Z]{3}[!A-Z]”)
f = open(”mess.txt”, “r”)
myout = target.findall(f.read())
And I got this:
In [7]: print myout
[’e’, ‘i’, ‘z’, ‘r’, ‘v’, ‘g’, ‘b’, ‘m’, ’s’, ‘z’, ‘u’, ‘o’, ‘w’, ‘i’, ‘b’, ‘z’, ‘b’, ‘c’, ‘j’, ‘g’, ‘d’, ‘o’, ‘h’, ‘l’, ‘
z’, ‘x’, ‘j’, ‘v’, […]
First of all I checked the lib to see if there’s an OCR module, looks no, at least not in the standard distribution
OK, it says to find the rare chars, so here is my first try:
f = open("mess.txt", "r")
ss = {}
for c in f.read():
if ss.has_key(c):
ss[c] += 1
else:
ss[c]=1
And here is the output:
In [6]: ss
Out[6]:
{’\n’: […]
After staring at the mess sentence at the end for a while, I realize there’s not too mucy “k,o,e” in it so the idea yesterday won’t work.
Look again at the pic and I think I found what’s in it: int(k)+2 = m, int(o)+2 = q, int(e)+2 = g. I think this is it.
It took me […]
OK, this is marked as “warming up” so it should be easy.
The hint is “look at the URL address.”. OK, this is challenge 0 and the url is 0.html. So I changed it to 1.html.
There is a page there! It shows “2**38 is much much larger.”. OK I know what the “238″ in the pic […]