Created
January 19, 2014 05:46
-
-
Save Glench/8500915 to your computer and use it in GitHub Desktop.
Get all the caesar ciphers for a given string.
This file contains hidden or 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
# print all caesar ciphers | |
# python caesar.py word | |
import sys | |
for offset in range(1,26): | |
word = '' | |
for letter in sys.argv[1].lower(): | |
num_of_letter = ord(letter) | |
new_num = num_of_letter + offset | |
if new_num > ord('z'): | |
new_num -= 26 | |
elif new_num < ord('a'): | |
new_num += 26 | |
word += chr(new_num) | |
print offset, word |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment