Reverse Rot
Time limit1sMemory limit256 MB
Reverse each message, then shift every character forward by N places in the 28-symbol alphabet.
- Level
Easy1 of 10
- Topics
- String, Simulation
- Solved
- No attempts yet
Problem
Rotating every character of an alphabet by a fixed number of places and rewriting the text is a very simple way to hide it. ROT13, which rotates the letters A to Z by 13 places, works that way, and programs used it to hide data from the late 1990s into the early 2000s.
This problem adds one step to that idea. Reverse the whole string first, then rotate every character forward. For example, reversing ABCD gives DCBA, and rotating that by 1 gives EDCB.
A message consists of capital letters, underscores and periods only. Rotation follows this order.
ABCDEFGHIJKLMNOPQRSTUVWXYZ_.
The underscore comes after Z, and the period comes after the underscore. A forward rotation of 1 turns A into B and B into C, and in the same way Z into _, _ into ., and . into A. A rotation of 3 turns A into D and B into E, and in the same way . into C.
Input
Each line holds an integer and a string, separated by one space. is the amount of forward rotation, and . The string is the message to encrypt. Its length is 1 to 40, and it uses capital letters, underscores and periods only. A line holding only the number 0 marks the end of the input.
Output
For each message, print the result of reversing it and then rotating it, one message per line.