Submit solution

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

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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

Qx Bek Oazsdaa

Sample Output

El Psy Congroo


  • 0
    Bossjr  commented on Dec. 24, 2019, 8:21 p.m.

    Whoever made the test cases, must love anime.

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

    Will the entire input be on one line, always?

    • 0
      DKLS2  commented on May 21, 2017, 8:10 p.m.

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

      • 0
        Pleedoh  commented on May 21, 2017, 8:20 p.m.

        Yeah I got it, thanks

  • 0
    Quality_of_Perfection  commented on June 30, 2016, 9:33 p.m.

    Java is no longer available on the languages bar when you submit the code.

  • 3
    Oppenheimer  commented on April 10, 2015, 2: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.

    • 7
      Phoenix1369  commented on April 10, 2015, 5: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 18, 2015, 10:06 p.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.

    • -1
      FatalEagle  commented on March 18, 2015, 11:07 p.m.

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