Canadian Computing Competition: 2012 Stage 1, Junior #4
Sheldon and Leonard are physicists who are fixated on the BIG BANG theory. In order to exchange secret insights they have devised a code that encodes UPPERCASE words by shifting their letters forward.
Shifting a letter by positions means to go forward letters in the alphabet. For example, shifting
B by positions gives
E. However, sometimes this makes us go past
Z, the last letter of the alphabet. Whenever this happens we wrap around, treating
A as the letter that follows
Z. For example, shifting
Z by positions gives
Sheldon and Leonard's code depends on a parameter and also varies depending on the position of each letter in the word. For the letter at position , they use the shift value of .
For example, here is how
ZOOM is encoded when . The first letter
Z has a shift value of ; it wraps around and becomes the letter
F. The second letter,
O, has and becomes
X. The last two letters become
B. So Sheldon sends Leonard the secret message:
Write a program for Leonard that will decode messages sent by Sheldon.
The input will be two lines. The first line will contain the positive integer (), which is used to compute the shift value. The second line of input will be the word, which will be a sequence of uppercase characters of length at most .
The output will be the decoded word of uppercase letters.
Sample Input 1
Output for Sample Input 1
Sample Input 2
Output for Sample Input 2