## Encode

View as PDF

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 of no more than characters and the shift count (), output the decoded string.

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

#### Input Specification

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

The decoded .

#### Sample Input

12
Qx Bek Oazsdaa

#### Sample Output

El Psy Congroo

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

Will the entire input be on one line, always?

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

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

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

Yeah I got it, thanks

• 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.

• 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.

• 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.

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

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