Problem Statement
Some texts contain hidden messages. In the context of this problem, the hidden message of a text is composed of the first letter from each word in the text, in the order they appear.
Given a
Definition
- Class:
- HiddenMessage
- Method:
- getMessage
- Parameters:
- String
- Returns:
- String
- Method signature:
- String getMessage(String text)
- (be sure your method is public)
Constraints
- text will contain between 1 and 50 characters, inclusive.
- Each character of text will be either a lowercase letter ('a'-'z'), or a space (' ').
Examples
"compete online design event rating"
Returns: "coder"
Taking the first letter from each word yields the return "coder".
" c o d e r "
Returns: "coder"
Watch out for the leading spaces.
"round elimination during onsite contest"
Returns: "redoc"
"coder" written backwards.
" hello world "
Returns: "hw"
"the quick brown fox jumped over the lazy dog "
Returns: "tqbfjotld"
" this is the easy problem "
Returns: "titep"
" "
Returns: ""
" a "
Returns: "a"
"a a a a a a a a a a a a a a a a a a a a a a a a a"
Returns: "aaaaaaaaaaaaaaaaaaaaaaaaa"
"a a a a a a a a a a a a a a a a a a a a a a a a a "
Returns: "aaaaaaaaaaaaaaaaaaaaaaaaa"
"this solution passes"
Returns: "tsp"
" aaaaaaaaaa aaaaaaaaaaaaa a"
Returns: "aaa"
" return the hidden message "
Returns: "rthm"
"interesting exercise for learning how to program"
Returns: "ieflhtp"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Returns: "x"
"y"
Returns: "y"
" "
Returns: ""
Since there are no words here, the empty string must be returned.
" c plus plus java c sharp basic "
Returns: "cppjcsb"
" dice gambling las vegas"
Returns: "dglv"
" soccer basketball volleyball "
Returns: "sbv"
" id wht omanly heay atuss n macon "
Returns: "iwohanm"
"fun fun fun fun fun fun fun fun fun fun fun fun"
Returns: "ffffffffffff"
" generating random text "
Returns: "grt"
" sdss dsdd sdddsssddsd dssds sdddsdsds"
Returns: "sdsds"
"fjd vasdkop asbdu ksaldhr alsk fhfjkas lsdkre o"
Returns: "fvakaflo"
" sdfauier sduioio ertwmn looopa fds"
Returns: "sself"
" agree tonight sounds pain "
Returns: "atsp"
" nobody change now"
Returns: "ncn"
"no on no on no on no"
Returns: "nononon"
"this is the last test case"
Returns: "titltc"
" "
Returns: ""
" dd"
Returns: "d"
"c r"
Returns: "cr"
" c o d e r "
Returns: "coder"
" c"
Returns: "c"
"aaa bbb"
Returns: "ab"
"z"
Returns: "z"
" "
Returns: ""
"aaaaaaa d"
Returns: "ad"