A relay beacon transmits each message after encoding it with a Caesar wheel: every letter of the original text was replaced by the letter k positions later in the lowercase alphabet, wrapping around from z back to a. The message contains only lowercase English letters.
Given the shift amount k and the encoded message, recover and print the original text by shifting every letter back by k positions (again wrapping around).
Line 1: an integer k, the shift that was applied during encoding.
Line 2: the encoded message, a non-empty string of lowercase English letters.
A single line: the decoded original message.
a-z).Example 1
Input
3 dwwdfn
Expected
attack
Explanation
Shifting each letter back by 3: d->a, w->t, w->t, d->a, f->c, n->k gives 'attack'.
Example 2
Input
0 hello
Expected
hello
Explanation
A shift of 0 means the encoded text equals the original, so it decodes to 'hello'.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →