Created
June 11, 2015 12:18
-
-
Save shionryuu/7027d30ca3dc2738d8fd to your computer and use it in GitHub Desktop.
Python Challenge 01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
# http://www.pythonchallenge.com/pc/def/map.html | |
import string | |
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. | |
''' | |
convert = lambda t: chr((ord(t) - ord('a') + 2) % 26 + ord('a')) | |
result = ''.join(convert(t) if 'a' <= t <= 'z' else t for t in text) | |
print result | |
# or | |
table = string.maketrans( | |
"abcdefghijklmnopqrstuvwxyz", "cdefghijklmnopqrstuvwxyzab" | |
) | |
print text.translate(table) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment