TopcoderArchive
SRM12 Mar 2010
SRM 486

TxMsg

Problem statement, definition, constraints, and public examples.

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.
For instance, "ps i love u" would be abbreviated as "p i lv u" while "please please me" would be abbreviated as "ps ps m".

You will be given the original message in the String original. Return a String with the message abbreviated using the described strategy.

Definition

Class:
TxMsg
Method:
getMessage
Parameters:
String
Returns:
String
Method signature:
String getMessage(String original)
(be sure your method is public)

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

  1. "text message"
    Returns: "tx msg"
  2. "ps i love u"
    Returns: "p i lv u"
    First example from the problem statement.
  3. "please please me"
    Returns: "ps ps m"
    Second example from the problem statement.
  4. "back to the ussr"
    Returns: "bc t t s"
  5. "aeiou bcdfghjklmnpqrstvwxyz"
    Returns: "aeiou b"
Back to all problems