Wednesday, November 5, 2014

Python: Python Challenge - Level 1 : Proposed Solution

Second problem on "pythonchallenge.com" is an image which displays the offset of alphabets we should apply in the given string below the image. To solve this, I tried the following Solution:

 uRLStringConstant = "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."  
 listSet=[]  
 for i in uRLStringConstant:  
      convertedValue = ord(i) +2  
      if convertedValue > 122:  
           convertedValue = 97  
      if convertedValue == 34:  
           convertedValue = 32  
      if convertedValue == 48:  
           convertedValue = 46  
      convertedCharater = chr(convertedValue)  
      listSet.append(convertedCharater)  
 print '[%s]' % ''.join(map(str, listSet))  

Output was:
 :::::OUTPUT::::::  
 Using 'map', we convert it to 'ocr'  
 Hence the URL is http://www.pythonchallenge.com/pc/def/ocr.html  

More suggestion are always welcome. In case if you wish me to write about any specific scenario, please feel free to write to me or else you can Comment below.

No comments:

Post a Comment