Hidden Words
InterviewTime limit2sMemory limit1024 MB
Starting from the first character, each letter tells how many positions ahead the next character is; output every visited character.
- Level
Easy2 of 10
- Topics
- String, Simulation, Implementation
- Solved
- No attempts yet
Problem
Anna sends secret encrypted messages to Bert. To read the messages, Bert must decrypt them with the following algorithm:
- The first character of the input string is included in the output string.
- Each character that is included states where in the input string the next character to include is found. An 'A' means the next character is 1 position ahead, a 'B' means 2 positions ahead, and so on.
- When the last character of the input is reached, that character is included and the process is done. The input is such that the last character is always reached.
Help Bert by writing a program that decrypts Anna's messages.
Input
The first and only line of the input contains the encrypted string (at most 50 characters). The string can be decrypted with the algorithm described above without going past the last character.
Output
Print the decrypted string.