Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simple and eazy solution in Clear category for Atbash Cipher by tamagoyaki
def atbash(plaintext: str) -> str:
# your code here
Plain="abcdefghijklmnopqrstuvwxyz"+"abcdefghijklmnopqrstuvwxyz".upper()+plaintext
Cipher="zyxwvutsrqponmlkjihgfedcba"+"zyxwvutsrqponmlkjihgfedcba".upper()+plaintext
return "".join([Cipher[Plain.index(i)] for i in plaintext])
if __name__ == "__main__":
print("Example:\nplaintext: testing")
print(atbash("testing"))
# These "asserts" are used for self-checking and not for an auto-testing
assert atbash("testing") == "gvhgrmt"
assert atbash("attack at dawn") == "zggzxp zg wzdm"
assert atbash("Hello, world!") == "Svool, dliow!"
print("Coding complete? Click 'Check' to earn cool rewards!")
Oct. 10, 2023
Comments: