Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
ascii_lowercase/maketrans/translate solution in Clear category for Caesar Cipher (decryptor) by bravebug
from string import ascii_lowercase
def to_decrypt(cryptotext, delta):
cryptotext = "".join([x for x in cryptotext if x == " " or x.islower()])
abc_mod = ascii_lowercase[delta:] + ascii_lowercase[:delta]
abc_tran = str.maketrans(ascii_lowercase, abc_mod)
return cryptotext.translate(abc_tran)
if __name__ == '__main__':
print("Example:")
print(to_decrypt('abc', 10))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert to_decrypt("!d! [e] &f*", -3) == "a b c"
assert to_decrypt("x^$# y&*( (z):-)", 3) == "a b c"
assert to_decrypt("iycfbu!@# junj%&", -16) == "simple text"
assert to_decrypt("*$#%swzybdkxd !)(^#%dohd", -10) == "important text"
assert to_decrypt("fgngr **&&frperg^__^", 13) == "state secret"
print("Coding complete? Click 'Check' to earn cool rewards!")
April 26, 2020