Skip to content

Instantly share code, notes, and snippets.

@Sasszem
Created April 14, 2020 19:09
Show Gist options
  • Save Sasszem/0e131941c9419cf6d4863ccb11bd3979 to your computer and use it in GitHub Desktop.
Save Sasszem/0e131941c9419cf6d4863ccb11bd3979 to your computer and use it in GitHub Desktop.
Smart atbash coding in Python
def swap(char):
return chr(swap_ascii(ord(char)))
def swap_ascii(code):
if code>=65 and code<=90:
return 155-code
# 90 - (code-65) = 90+65-code = 115-code
elif code>=97 and code<=122:
return 219-code
# similarly from 112-(code-97)
return code
def atbash(string):
return "".join(map(swap, string))
while True:
print(atbash(input()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment