Monthly Archives May 2005

Challenge 5

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 […]

tla problem today

Well I’m using the unicode version of Emacs, and while I’m committing a big merge to the tla archive via xtla, Emacs crashed.
After I restart Emacs and do the commit again, tla won’t work, the error message is:
arch_commit: unable to acquire revision lock (could not rename file.)
Searched google and there are several reasons/solutions for this:
1. […]

Challenge 6

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 […]

Challenge 4

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
&#60;font color=red&gt;Your hands are getting tired &#60;/font&gt;and the next nothing is 50010
and the next […]

Challenge 3

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’, […]

Challenge 2

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’: […]

Challenge 1

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 […]

There are three kind of problems: direct, indirect, or no control

No matter which one we got, we have the first step to the solution: Changing our habits for direct problem, changing our methods of influence for indirect problem, and changing the way we see the problems that we have no control.

Share This

Challenge 0

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 […]

sqlobject in one file

Looks if two SQLObject class got reference to each other, i.e,
ForeignKey
, they should stay in the same file. Else the generated reference column name will get messed up and causing problem. This is where I wasted 3 hours today
Also the column name should be in mixedCase instead of
MixedCase
. This should be a bug […]

Close
E-mail It