Archive for September 7, 2007

Python Challenge level 1: “what about making trans?”

Level 1 gets a bit more interesting.
Hint 1: k->m, o->q, e->g

import string
src = string.lowercase[:26]
dst = string.lowercase[2:26] + 'ab'
trans = string.maketrans(src, dst)
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."
print text.translate(trans)

That gives:

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.

Ha, funny! Ok then, an extra:

print "map".translate(trans)

ocr

That gets us to Level 2.

Read the rest of this entry »

Python Challenge level 0: “warming up!”

I recently discovered the Python Challenge web site. An interesting way to pick up a programming language. It claims to be the first programming riddle on the net, and I have been told that it’s shaped after another onlin games that predates this one by more than a year, notprOn. It turns out the Python Challenge has been around since 2005, but I had no clue about Python by then anyway. It’s really a pity because I’m addicted to the game as it is, so I’m quite sure I would have started learning a lot earlier for amusement’s sake.

Some of the puzzles are a bit obscure IMHO, but nevertheless it’s worth it. It has 33 levels and it gradually introduces you to Python specifics. Most levels could be solved with other languages, but it’s a good way of showing Python’s impressive resources.

I’ve been talking to some friends about it, and it looks like a whole new bunch of addicts is on the way ;) Since I really do love puzzles, one of them conviced me to post every solution I come up with so that we can all compare our results. I’ll try, at least until I get completely stuck. Hopefully I’ll find enough hints in the forums and among these friends. I’m allready at level 17, by the way. I’ll be posting on a more or less daily basis so that everyone can catch up.

Warning: You should only read these Python Challenge Chronicles of mine if you are really stuck on some point. Otherwise you’ll only end up spoiling your fun. As in every game, the interest is in onvercoming the challenges on your own. When you play in God-mode (prince megahit, anyone?) it get’s boring pretty fast. Besides… the challenges are really well thought. You should give it a try, resort to the forums for hints when you’re stuck, and only after that …

Level 0 doesn’t even need a script to be solved. It’s just a warm up to introduce the player to the game. The hint given is ‘try to change the url’ and an image showing 2^38, so we use our Python interpreter to find out the result:

>>> 2**38
274877906944L

And with that we’re on our way to all the fun on Level 1

Read the rest of this entry »