Secret Chat
Здравейте, можели малко помощ не мога да си намеря грешката 87/100 ми дава
кода ми https://pastebin.com/xVyaYLaK
Secret Chat
You have plenty of free time, so you decide to write a program that conceals and reveals your received messages. Go ahead and type it in!
On the first line of the input you will receive the concealed message. After that, until the "Reveal" command is given, you will be receiving strings with instructions for different operations that need to be performed upon the concealed message in order to interpret it and reveal its true content. There are several types of instructions, split by ":|:"
- InsertSpace:|:{index}
- Inserts a single empty space at the given index. The given index will always be valid.
- Reverse:|:{substring}
- If the message contains the given substring, cut it out, reverse it and add it at the end of the message.
- If not, print "error".
- This operation should replace only the first occurrence of the given substring if there are more than one such occurrences.
- ChangeAll:|:{substring}:|:{replacement}
- Changes all occurrences of the given substring with the replacement text.
Input / Constraints
- On the first line, you will receive a string with message.
- On the next lines, you will be receiving commands, split by ":|:".
Output
- After each set of instructions, print the resulting string.
- After the "Reveal" command is received, print this message:
"You have a new text message: {message}"
Examples
Input |
Output |
heVVodar!gniV ChangeAll:|:V:|:l Reverse:|:!gnil InsertSpace:|:5 Reveal |
hellodar!gnil hellodarling! hello darling! You have a new text message: hello darling! |
Comments |
|
ChangeAll:|:V:|:l Reverse:|:!gnil hellodar!gnil -> !gnil -> ling! -> hellodarling! (We reverse !gnil to ling! And put it in the end of the string) InsertSpace:|:5 hellodarling! -> hello.darling! (We insert a space at index 5) Finally, after receiving the "Reveal" command, we print the resulting message. |
|
Input |
Output |
Hiware?uiy ChangeAll:|:i:|:o Reverse:|:?uoy Reverse:|:jd InsertSpace:|:3 InsertSpace:|:7 Reveal |
Howare?uoy Howareyou? error How areyou? How are you? You have a new text message: How are you? |
Много ти благодаря счупих се да мисля:)
често чуждото око вижда по-лесно нашите малки грешки :)
🙆