Skip to content

Instantly share code, notes, and snippets.

@shionryuu
Created June 11, 2015 12:18
Show Gist options
  • Save shionryuu/7027d30ca3dc2738d8fd to your computer and use it in GitHub Desktop.
Save shionryuu/7027d30ca3dc2738d8fd to your computer and use it in GitHub Desktop.
Python Challenge 01
#!/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