[Exercises] Programming Fundamentals -More Exercises: Strings And Text Processing - Problem {3} - Karate Strings
1. Karate Strings
The most notorious person in SoftUni – Pesho is trying to become a karate master. Being a programmer, Pesho has no idea how to train, so he decided to train on strings.
His punches are marked with ‘>’. Immediately after the mark, there will be an integer, which signifies the strength of the punch.
You should remove x characters (where x is the strength of the punch), starting after the punch character (‘>’).
If you find another punch mark (‘>’) while you’re deleting characters, you should add the strength to your previous punch.
When all characters are processed, print the string without the deleted characters.
You should not delete the punch character – ‘>’, but you should delete the integers, which represent the strength.
Input
You will receive single line with the string, which is used by Pesho for training.
Output
Print what is left from the string after Pesho’s punches.
Constraints
· You will always receive a strength for the punches
· The path will consist only of letters from the Latin alphabet, integers and the char ‘>’
· The strength of the punches will be in the interval [0…9]
Examples
Input |
Output |
Comments |
abv>1>1>2>2asdasd
|
abv>>>>dasd |
1st punch is at index 3 and it is with strength of 1. We delete only the digit after the punch character. The string will look like this: abv>>1>2>2asdasd 2nd punch is with strength one and the string transforms to this: abv>>>2>2asdasd 3rd punch is now with strength of 2. We delete the digit and we find another punch. At this point the string looks like this: abv>>>>2asdasd. 4th punch is with strength 2. We have 1 strength left from the previous punch, we add the strength of the current punch to what is left and that adds up to a total strength of 3. We delete the next three characters and we receive the string abv>>>>dasd We do not have any more punches and we print the result: abv>>>>dasd |
Input |
Output |
pesho>2sis>1a>2akarate>4hexmaster |
pesho>is>a>karate>master |
Не мога да си намеря грешката
Judge ми дава 66 точки ( 2-ра и 6-та проверка ми гърми )
Ето го и кода ми :
https://pastebin.com/ziRcp2eG
Мерси !