Skip to content

Instantly share code, notes, and snippets.

@sauravtom
Last active December 14, 2015 12:59
Show Gist options
  • Select an option

  • Save sauravtom/5090467 to your computer and use it in GitHub Desktop.

Select an option

Save sauravtom/5090467 to your computer and use it in GitHub Desktop.
My solution python challenge 1 http://www.pythonchallenge.com/pc/def/map.html
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.'''
def trans(string):
poop=''
for i in string:
#if i in ['.' , ',' , ')' , '(' , "'"," "]: #dont translate special characters
if in in " .,'():;":
poop+=i
else:
if ord(i)<ord('y'):
poop+=chr(ord(i)+2)
else: # we dont want { to come after(in ascii code) z , instead of a, do we ?
poop+=chr(ord(i)-24)
return poop
print text
print trans(text)
print trans('map')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment