Home > Python, PythonChallenge.Com > PythonChallenge – Level 1

PythonChallenge – Level 1


Homepagehttp://www.pythonchallenge.com/pc/def/map.html

How I solve:

– According to the picture, I can see that this might relate to character transformation; it is a conversion letter map,

K->M

O->P

E->G

– So first try is to convert the input data following this map

from string import maketrans

data = "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."

table_from = "koe"
table_to = "mpg"

print data.translate(maketrans(table_from, table_to))

– Well the result is un-readable. So I try to expand it to whole alphabet table, because it maps each letter by the next two letter on the alphabet. Make another try:

from string import maketrans

data = "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."

table_from = "abcdefghijklmnopqrstuvwxyz"
table_to = "cdefghijklmnopqrstuvwxyzab"

print data.translate(maketrans(table_from, table_to))

– Now the result is very human-readable.

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.

– Oh, so apply for the url, I reach the next level 🙂

Cheers,
Pete Houston

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: