Statistics

Problem Statement for "TxMsg"

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"

  6. "nsemfeyzasv sufnoogbia cpevavuhja doolosofap"

    Returns: "nmys sfg cvvh dlsfp"

  7. "ilacaoyudia utjuviogofr wnoisduzelq oiwtasuewl"

    Returns: "lcyd tvgf wszl wsw"

  8. "iovhiduypoi oewuofeisl esyiasezae gyaiwozqup"

    Returns: "vdy wfs ssz gwzp"

  9. "iqdikixeex urzofegsutc ejmijhoife iovehoihox"

    Returns: "qkxx rfgt jjf vhhx"

  10. "jgouwborau lojaveuyodm inxuemguqd kutuaglexb"

    Returns: "jwr ljvyd nmq ktgx"

  11. "uelroibugoe qjodzoqeong iutarkogdaa eoziwhueyou"

    Returns: "lbg qdqn trg zwy"

  12. "mmuwiyriars ovvoceneqa icjeiqloeyd zoiswocbei"

    Returns: "mwyr vcnq cqy zsc"

  13. "loehufipnao ojoezaomsu ewahuxdequ nuoyeadoey"

    Returns: "lhfp jzm whxq nydy"

  14. "imuitoiwea oehehiqruwg ujuqxemuku zrutuyiulo"

    Returns: "mtw hhqw jqmk ztyl"

  15. "oxizburoih iezuxaolabx ghigotvicr talalgeodua"

    Returns: "xzrh zxlb ggtc tlld"

  16. "iudasliiyd jsotxuvarv aegoclisux giqecoktat"

    Returns: "dsy jtvr gcsx gqckt"

  17. "gsicziutqaa aramiagire ueggokjiuxc aurewaniesm"

    Returns: "gct rmgr gkx rwns"

  18. "opasfobtuo neuxuetasuu smudiiveix pueruozipe"

    Returns: "psb nxts sdvx przp"

  19. "luizvokileu eqewtaihoe juoskutevl xamxobyemy"

    Returns: "lzkl qwh jstv xmbm"

  20. "aarnoniacu vaakxaeyjaa hjoszuaraa iushaziladn"

    Returns: "rnc vky hsr szld"

  21. "uhpegeetea xafisirool ifuxuuwdua obuwumiatn"

    Returns: "hgt xfsrl fxw bwmt"

  22. "fuxcoqiunw dveqozowaa cepemapooxw eypuljifek"

    Returns: "fxqn dqzw cpmpx ylfk"

  23. "lozutuyumeo ialeegxokm rouykeutotz mefniorcun"

    Returns: "lztym lgk rytt mfrn"

  24. "neixajdifeu hgoufeweixp cuayriuzne ivibiqzedeo"

    Returns: "nxjf hfwx cyz vbqd"

  25. "ajiavqeflue koeleelnucx iodenouyua ojsicoumzo"

    Returns: "jvf kllc dny jcm"

  26. "gveraetaayh ofacigoabue qiekfebvesp lifaveirix"

    Returns: "grty fcgb qkbs lfvrx"

  27. "aawpopujoo yieruibuizf zzukluipalp bdoififracr"

    Returns: "wpj yrbz zkpl bffc"

  28. "gjeamodeha jegadcewoo toikuzobomd odanroslihk"

    Returns: "gmdh jgdw tkzbm dnsh"

  29. "amdohitucai eazefayutou voqcouyaxd zhagacozax"

    Returns: "mhtc zfyt vqyx zgczx"

  30. "geodiubtou oesuicioda ualiupheaqs uepeteqott"

    Returns: "gdb scd lpq ptqt"

  31. "ofisroucmo qciawraado nbusireykao oabihildir"

    Returns: "fsc qwd nsry bhlr"

  32. "eorokhicedv qolaebiaca laoyikoacea jednelzoef"

    Returns: "rkcd qlbc lykc jdlf"

  33. "uzookibize xioturdoup eaweuloruq iujeirdotii"

    Returns: "zkbz xtrp wlrq jrt"

  34. "oujguefrij enfoahijfo pbailorokio yoatnurieq"

    Returns: "jfj nhj plrk ytrq"

  35. "kyoruhiovw oojaiximinf huvegmuqzi wiunakilqi"

    Returns: "krhv jxmn hvgq wnkl"

  36. "yuxiocleord aelalgauyo ceiqusweka dkommainjo"

    Returns: "yxcr lly cqsk dmn"

  37. "uceuguvenoa cseibeawso adeloajnuzt eohzofrito"

    Returns: "cgvn cbw dljz hft"

  38. "oofemifipu zsouzauticv oeqokcanvo exoulsebui"

    Returns: "fmfp zztc qkn xlb"

  39. "iqdeumpaxu ituujnuvwi pocjoposed emfuonaixu"

    Returns: "qmx tjv pcpsd mnx"

  40. "ucasetiqei adiduwpeqj pekkobneesm julmuebtagq"

    Returns: "cstq ddwq pkbs jlbg"

  41. "uguoztaowie mkuivalhai oreuqociiw kizigbihaw"

    Returns: "gzw mvl rqcw kzghw"

  42. "hjeoyuaqak jiqeajerue lommiotiosl iarwikuayie"

    Returns: "hyqk jqjr lmts rky"

  43. "iigxuosani aivbiolaad oiyuibpixa ynemgednio"

    Returns: "gsn vld ybx ymd"

  44. "reuhzouyor knuqsinirie naqouhtuxeo oyihovcoit"

    Returns: "rhyr kqnr nqhx yhvt"

  45. "ibhonizfoe zquxaivfek wefuawumuz ufiecehyec"

    Returns: "bnz zxvk wfwmz fchc"

  46. "ibomsuizel ihboizciid eviorekzee ovidcocafeo"

    Returns: "bmzl hzd vrk vdcf"

  47. "axsemcubbo obifuafaln eyuavuirtio voryaheoju"

    Returns: "xmb bffl yvr vrhj"

  48. "pihehavekg eojdolvuyui cuocdoojeo eesehaogsea"

    Returns: "phhvk jly ccj shg"

  49. "yateovfiap wajxiavoca vaviiyeuvee akeluiboer"

    Returns: "ytvp wjvc vvyv klbr"

  50. "erauwroojj tukepedloo ereotaciyk roqaqeoqnei"

    Returns: "rwj tkpd rtcy rqqq"

  51. "whaaviluww cuexiapuhb efmendiwebl oegebofaig"

    Returns: "wvlw cxph fnwb gbfg"

  52. "awveqejagy vveidseelb toipibzoifg qsioboohliu"

    Returns: "wqjg vdl tpbf qbh"

  53. "uoteejihri deqwuwavse easouqaagai psuaqyuuqoa"

    Returns: "tjh dqwv sqg pqq"

  54. "iznipuuquc etoelzetic vimwutukjao gwahamzosia"

    Returns: "zpqc tltc vmtk ghms"

  55. "ifeejeirav exucaiyuons sbedtejmew ogboatemyeo"

    Returns: "fjrv xcyn sdjw gtm"

  56. "oexoyeadte toeyavvimv maaxezuiqo lzubuadovj"

    Returns: "xyd tyvm mxzq lbdv"

  57. "ufnoowubabv zojaugujho udizdogotq usuewejeuyt"

    Returns: "fwbb zjgj dzgt swjy"

  58. "iymuugwejii pazquuziop acapetihtu kzacuinrinh"

    Returns: "ygj pzzp cpth kcnn"

  59. "iaauaeuueeaoeauaeuoaioaueouuiaeaueouiiieeoaaoiueoi"

    Returns: "iaauaeuueeaoeauaeuoaioaueouuiaeaueouiiieeoaaoiueoi"

  60. "zvwmccbyrflsffzlnqqz iaaaiaeaiieiaaaaouia"

    Returns: "z iaaaiaeaiieiaaaaouia"

  61. "iaioiuieuoqcymqpyrljuaeieiaaeihtltnrylrteuueeaoeau"

    Returns: "qh"

  62. "aeuoaioauepbywhpkmztiaeaueouiibhppmlrtqzmfpkjdnzqp"

    Returns: "pb"

  63. "oaaoiueoiovcytkzhdylueeiaaaiaeaiieiaaaaoysqhdvjgvn"

    Returns: "vy"

  64. "uiaoieiuaalnqqzkcqhbldsmblbtmwoeeuaiuoiopzqhjsjtrh"

    Returns: "lp"

  65. "ueiaeoaueuztfynftdwqxmddbywfpmuoauauueuuoiooaeouia"

    Returns: "z"

  66. "ooooiuooieoauiiiueaatcryjfkzdfaoioeaeouobdmshczzxv"

    Returns: "tb"

  67. "eieioaeeeaioeoaiouoiwrczchskgcoouooeiieeueuiueeoae"

    Returns: "w"

  68. "jjkvvmzxjgoeeoaaoiuaiaeeaioiiegwxnnmvfmseoiieoeuuo"

    Returns: "jg"

  69. "fcpgsjngfbuuuioioeiiieuuuuuioofryqncmhnzghhpbcgpjx"

    Returns: "ff"

  70. "ntldzxrqrwtjlgktqbfhaoiouoouooltxpzmbllcuueuieeeoe"

    Returns: "nl"

  71. "ndngwmntblzsggtnqmhxoieoaaaueubbzhbqtvlfqykvpnrmfs"

    Returns: "nb"

  72. "tywhjqksrjbbwwhnnftdueiioieiiooaiaueuauorrndqtmmzz"

    Returns: "tr"

  73. "a"

    Returns: "a"

  74. "x"

    Returns: "x"

  75. "a b c d e f g h i j k l m n o p q r s t u v w x"

    Returns: "a b c d e f g h i j k l m n o p q r s t u v w x"

  76. "aaa oib uce cai hlo nim axy vtx y z ef go gt uu"

    Returns: "aaa b c c h nm x v y z f g g uu"

  77. "ooooo"

    Returns: "ooooo"

  78. "m m m m m m e m mm mm mm eeem eee mm"

    Returns: "m m m m m m e m m m m m eee m"

  79. "abd zzz iiio iide ozahaok"

    Returns: "b z iiio d zhk"

  80. "aiueo wowow ononono ghjk"

    Returns: "aiueo www nnn g"

  81. "ae"

    Returns: "ae"

  82. "aaa"

    Returns: "aaa"

  83. "yydd yyy jjjff jjj jj"

    Returns: "y y j j j"

  84. "iii rrr rirrriii ashhytt"

    Returns: "iii r rr s"

  85. "eyuioa"

    Returns: "y"

  86. "ps i love u aeiueo abfefbdkbfoiuiuochjjioihi"

    Returns: "p i lv u aeiueo bfch"

  87. "albbc acc lba oto yyy cnmlgb"

    Returns: "l c l t y c"

  88. "aaaa eee iii"

    Returns: "aaaa eee iii"

  89. "eeiou eee rtio"

    Returns: "eeiou eee r"

  90. "asdfssdf eaiaeia aifj jfsdkeia aia aiiai hjh jhhqq"

    Returns: "s eaiaeia f j aia aiiai h j"

  91. "ououssssssssssssssssssss qeqtygdzs"

    Returns: "s qq"

  92. "ttttt aaya"

    Returns: "t y"

  93. "a t"

    Returns: "a t"

  94. "ai iu ue eoiua aiusaeo stu sui sot a i u e o x"

    Returns: "ai iu ue eoiua s s s st a i u e o x"

  95. "aeiou"

    Returns: "aeiou"

  96. "za"

    Returns: "z"

  97. "a e i paer pae you uy"

    Returns: "a e i pr p y y"

  98. "aeappeeap"

    Returns: "pp"

  99. "ai p"

    Returns: "ai p"

  100. "aaaaeeee aaaaeeee"

    Returns: "aaaaeeee aaaaeeee"

  101. "akgh ijsd"

    Returns: "k j"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: