Last active
June 19, 2017 21:08
-
-
Save effective-light/64a9af009cdc8b5df253b6dc94574157 to your computer and use it in GitHub Desktop.
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
def bob_cipher(phrase: str, key: str) -> str: | |
""" | |
>>> bob_cipher("ANT", "BOB") | |
B25O25B18 | |
""" | |
new_s = "" | |
for key_char, phrase_char in zip(key, phrase): | |
key_ord = ord(key_char) | |
phrase_ord = ord(phrase_char) | |
if key_ord <= phrase_ord: | |
new_s += phrase_char + str(phrase_ord - key_ord) | |
else: | |
new_s += key_char + str(25) | |
return new_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment