TxMsg
SRM 486 · 2010-03-12 · by soul-net
SRM 486 · 2010-03-12 · by soul-net · String Manipulation
Problem Statement
Problem Statement
Strange abbreviations are often used to write text messages on uncomfortable mobile devices. One particular strategy for encoding texts composed of alphabetic characters and spaces is the following:
- Spaces are maintained, and each word is encoded individually. A word is a consecutive string of alphabetic characters.
- If the word is composed only of vowels, it is written exactly as in the original message.
- If the word has at least one consonant, write only the consonants that do not have another consonant immediately before them. Do not write any vowels.
- The letters considered vowels in these rules are 'a', 'e', 'i', 'o' and 'u'. All other letters are considered consonants.
You will be given the original message in the
Constraints
- original will contain between 1 and 50 characters, inclusive.
- Each character of original will be a lowercase letter ('a'-'z'), or a space.
- There will not be two consecutive spaces in original, nor will the first or last character be a space.
Examples
0)
"text message" Returns: "tx msg"
1)
"ps i love u" Returns: "p i lv u"
First example from the problem statement.
2)
"please please me" Returns: "ps ps m"
Second example from the problem statement.
3)
"back to the ussr" Returns: "bc t t s"
4)
"aeiou bcdfghjklmnpqrstvwxyz" Returns: "aeiou b"
Submissions are judged against all 101 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class TxMsg with a public method string getMessage(string original) · 101 test cases · 2 s / 256 MB per case