Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Scytale Encryption by mortonfox
def scytale_decipher(ciphertext: str, crib: str):
res = None
for key in range(2, len(ciphertext)):
decr = ''.join(ciphertext[i::key] for i in range(0, key))
if crib in decr:
if res: return
res = decr
return res
if __name__ == "__main__":
print("Example:")
print(scytale_decipher("aaaatctwtkdn", "dawn"))
# These "asserts" are used for self-checking and not for an auto-testing
assert scytale_decipher("aaaatctwtkdn", "dawn") == "attackatdawn"
assert scytale_decipher("hdoeerlallrdow", "world") == "hellodearworld"
assert (
scytale_decipher("totetshpmeecisendysescwticsriasraytlaegphet", "sicret")
== None
), "Crib is not in plaintext"
assert (
scytale_decipher("aaaatctwtkdn", "at") == None
), "More than one possible decryptions"
print("Coding complete? Click 'Check' to earn cool rewards!")
Dec. 13, 2021