Editor

Atbash Cipher

#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.

Examples

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.

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.