27 lines
543 B
Python
27 lines
543 B
Python
# solve.py
|
|
# Reverse the shifting to recover the original plaintext
|
|
|
|
def unshift_letter(letter, shift):
|
|
start = ord('A') if letter.isupper() else ord('a')
|
|
return chr(start + (ord(letter) - start - shift) % 26)
|
|
|
|
|
|
def solve(encoded):
|
|
out = ""
|
|
i = 25 # starting shift
|
|
|
|
for c in encoded:
|
|
if c in ['{', '}', '_']:
|
|
out += c
|
|
continue
|
|
|
|
out += unshift_letter(c, i)
|
|
i -= 1
|
|
|
|
return out
|
|
|
|
|
|
if __name__ == "__main__":
|
|
a = 'BRC{ivex_uruhoe_otzqmy_mwidv_bgzgk}'
|
|
print(solve(a))
|