codeblock

2016年3月24日 星期四

Python Challenge level 1

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

- observe the picture, there are all 2 lexicographical difference between each pairs of letters
- not sure what the tip means is
  1. k should be changed to m
  2. in the cipher text, k is changed to m

- see the first word "g", guess it means "I"
- replace all the letters with the letter after the next one
a = "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."
a = list(a)
b = range(len(a))
for i in range(len(a)):
 if ord(a[i]) >= ord('a') and ord(a[i]) <= ord('z'):
  b[i] = chr(ord(a[i])+2) if (ord(a[i])+2 <= ord('z')) else chr(ord(a[i])-ord('z')+ord('a')+1) 
 else:
  b[i] = a[i]
b = ''.join(b)
print b
- The plain text is
"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."
Apparently the author wants us to use string.maketrans function :)
- apply again use the string "map" in url, you get "ocr"

沒有留言:

張貼留言