icpc probs
This commit is contained in:
parent
4c531b965f
commit
69d48861b1
17 changed files with 448 additions and 2 deletions
22
kattis/23-9-24/e/solution.py
Normal file
22
kattis/23-9-24/e/solution.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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))
|
||||
Loading…
Add table
Add a link
Reference in a new issue