SMSLanguage
SRM 356 · 2007-07-02 · by Pawa
SRM 356 · 2007-07-02 · by Pawa · String Parsing
Problem Statement
Problem Statement
SMS messages are short messages sent between mobile phones. The maximum length of a single message is 160 characters, so it is often necessary to abbreviate words.
You are given a
- Remove all punctuation symbols ('.', ',', '?' and '!').
- Replace all uppercase letters with their lowercase equivalents.
- Replace all occurrences of "and" with '&'.
- Replace all occurrences of "ate" with '8'.
- Replace all occurrences of "at" with '@'.
- Replace all occurrences of "you" with 'U'.
Return the resulting translation as a
Constraints
- text will contain between 1 and 50 characters, inclusive.
- text will contain only letters ('a'-'z', 'A'-'Z'), the characters ',', '.', '!', '?', and spaces (' ').
Examples
0)
"I HATE rats, and you?" Returns: "i h8 r@s & U"
The example from the problem statement.
1)
"What is the weather like today?" Returns: "wh@ is the we@her like today"
2)
"It is not too late to.." Returns: "it is not too l8 to"
3)
"this text is already in sms language" Returns: "this text is already in sms language"
4)
"only yoyoyou" Returns: "only yoyoU"
Submissions are judged against all 73 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class SMSLanguage with a public method string translate(string text) · 73 test cases · 2 s / 256 MB per case