Created
December 19, 2011 23:32
-
-
Save jotbe/1499424 to your computer and use it in GitHub Desktop.
AI-Class: Optional NLP Programming Task (Part One - Rotation Cipher)
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
#!/bin/env python | |
""" | |
Optional NLP Programming Task - Part One (Rotation Cipher) | |
========================================================== | |
""" | |
__author__ = 'Jan Beilicke <dev +at+ jotbe-fx +dot+ de>' | |
__date__ = '2011-12-19' | |
if __name__ == '__main__': | |
code = 'Esp qtcde nzyqpcpynp zy esp ezatn zq Lcetqtntlw Tyepwwtrpynp hld spwo le Olcexzfes Nzwwprp ty estd jplc.' | |
alphabet = 'abcdefghjiklmnopqrstuvwxyz' | |
for i in range(25): | |
out = '' | |
for character in code.lower(): | |
if character == ' ': | |
out += ' ' | |
continue | |
char_pos = alphabet.find(character) | |
subst_char_pos = (char_pos - i) % len(alphabet) | |
out += alphabet[subst_char_pos] | |
print i, '=>', out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment