#211 · Codes and ciphers · Beginner · 30 XP · about 6 min
Atbash is one of the oldest known ciphers. It writes the alphabet backwards under itself and swaps each letter for the one opposite it: A becomes Z, B becomes Y, C becomes X, and so on, up to M and N, which swap with each other.
Write atbash(text) that returns the Atbash version of text. Lower case letters are swapped the same way and stay lower case (a becomes z), capital letters stay capital, and every other character (spaces, digits, punctuation) is copied unchanged.
atbash("Hello, World!") # returns 'Svool, Dliow!' atbash("wizard") # returns 'draziw' atbash("Svool") # returns 'Hello'
Because the swap is a mirror, encrypting twice brings the original message back, so the same function also decrypts.
First solves only, ranked by stars and then time.