Skip to content

Instantly share code, notes, and snippets.

@jotbe
Created December 19, 2011 23:32
Show Gist options
  • Save jotbe/1499424 to your computer and use it in GitHub Desktop.
Save jotbe/1499424 to your computer and use it in GitHub Desktop.
AI-Class: Optional NLP Programming Task (Part One - Rotation Cipher)
#!/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