cp/kattis/23-9-24/e/solution.py
2026-01-07 12:30:51 -06:00

22 lines
513 B
Python

ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_."
character_to_index = {c: i for i, c in enumerate(ALPHABET)}
index_to_character = {i: c for i, c in enumerate(ALPHABET)}
while line := input():
split = line.split()
if len(split) == 1:
break
k, string = int(split[0]), split[1]
backwards = string[::-1]
ans: list[str] = []
for letter in backwards:
index = character_to_index[letter]
ans.append(index_to_character[(index + k) % len(ALPHABET)])
print("".join(ans))