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 some time cause Python don’t do the type cast as we do in c/cpp. I checked the manual with keyword like “char” “ascii” and found curses.ascii and binascii. The curses.ascii might be some help but not what I want. Finally I found str() and ord(). So here is the first version:
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.
"""
def add2(s):
return [chr(ord(i)+2) for i in s]
Ooops, it print one char per line.
So here is the second version:
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.
"""
def add2(s):
return “”.join([chr(ord(i)+2) for i in s])
I got
Out[33]: ‘\x0ci"hope"you"didnt"tr{nsl{te"it"|y"h{nd0"th{ts"wh{t"computers"{re"for0"doing"it\x0cin"|y"h{nd"is"inefficient"{
nd"th{t)s"why"this"text"is"so"long0"using\x0cstring0m{ketr{ns*+"is"recommended0"now"{pply"on"the"url0\x0c’
Hmm, I should make that in one line and convert alphas only.
Wait… I saw something about string in it. Let me check the document…
OK, I’ve found string.maketrans() and string.translate(). So here is the third version:
sentence = “\
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. \
”
trans = string.maketrans(”abcdefghijklmnopqrstuvwxyz”,
“cdefghijklmnopqrstuvwxyzab”)
def add2(s):
return string.translate(s, trans)
And now
Out[46]: "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.\n"
OK, I’ve got it!
Out[48]: ‘ocr’
So the next challenge is at http://www.pythonchallenge.com/pc/def/ocr.html
One more thing about this challenge: the title is “What about making trans?”. That is a hint too.
Now challenge 2: the hint is “recognize the characters. maybe they are in the book, but MAYBE they are in the page source.” View the html source and found “find rare characters in the mess below:” and some mess of characters. This looks like base64 or uuencoded. Let’s wait for tomorrow.
Tags: python_challenge, python, python-challenge
Comments 3
ok in challenge 2 source code i foun in the “mess” this letters in this order
Posted 12 Jun 2008 at 4:22 pm ¶equality
dunno what to do with it XD
XD just type it in the adress
Posted 12 Jun 2008 at 4:22 pm ¶http://www.pythonchallenge.com/pc/def/equality.html
Thanks man. I’ve been stopped at challenge 6 and haven’t been played with it for a while. Wish you good luck
Posted 12 Jun 2008 at 7:12 pm ¶Post a Comment
You could use <code type="name"> to get your code colorized