Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Problem type

In a Caesar cipher, all characters in an input string are shifted by a number of positions. In other words, with a shift of 3 A becomes D, while with a shift of -2 F becomes D. Given an encoded string S of no more than 1000 characters and the shift count N (-1000 \le N \le 1000), output the decoded string.

Note that S will only ever contain alphabetical characters and spaces. Also note that an S containing Z shifted by an N of 2 is perfectly valid, so you should wrap around to B. Letter casing matters!

Input Specification

On one line, N, followed by S on a separate line.

Output Specification

The decoded S.

Sample Input

12
Qx Bek Oazsdaa

Sample Output

El Psy Congroo

Comments


  • 0
    Pleedoh  commented on May 20, 2017, 5:38 p.m.

    Will the entire input be on one line, always?


    • 0
      DKLS2  commented on May 22, 2017, 12:10 a.m.

      If you mean the text that will be decoded than yes.


      • 0
        Pleedoh  commented on May 22, 2017, 12:20 a.m.

        Yeah I got it, thanks


  • 3
    Oppenheimer  commented on April 10, 2015, 6:51 p.m.

    Sorry, this may be dumb of me but how does Q become E? Shifting Q 12 spaces gets me to C, not E. Am I missing something here? If someone could clarify this, it would greatly be appreciated.


    • 6
      Phoenix1369  commented on April 10, 2015, 9:46 p.m.

      Although the problem is called Encode, you are actually supposed to output the decoded string. You shift to the right when you encode, so you should shift the other way when decoding.


  • 2
    Hunterdrago1  commented on March 19, 2015, 2:06 a.m.

    If you guys have the time, can you reword this problem? In the beginning, I thought n=12 would result in Q wrapping around to C, and not the other way around. Thanks.


    • -3
      FatalEagle  commented on March 19, 2015, 3:07 a.m.

      It says "Given an encoded string, output the decoded string".