Given a string as input, output the string with the following algorithm applied:
1. Split the String by " " (find the words): "Hello World" -> ["Hello","World"]
2. Find the vowel count of each component: [2,1] ( ["H[e]ll[o]","W[o]rld"] )
3. For each of the components, output the first n letter where n is the number
of vowels it contains: ["He","W"]
4. Join the list to a single string and reverse it: "HeW" -> "WeH"
Specs
You may take input and provide output by any standard form, and the only data type allowed for both Input and Output is your language's native String type. Taking input directly as a list of individual words is not permitted.
You are guaranteed that there will be no consecutive spaces.
The vowels are
"a","e","i","o","u","A","E","I","O","U"
, but"y","Y"
are not considered vowels.You are guaranteed that only letters and spaces will appear in the input, but without any newlines.
Output must be case-sensitive.
You are not guaranteed that each word contains a vowel. If no vowels appear in that word, you do not have to output anything for it.
Test Cases
Input -> Output
---------------
"" -> ""
"Hello World" -> "WeH"
"Waves" -> "aW"
"Programming Puzzles and Code Golf" -> "GoCauPorP"
"Yay Got it" -> "iGY"
"Thx for the feedback" -> "eeftf"
"Go Cat Print Pad" -> "PPCG"
"ICE CREAM" -> "RCCI"
Scoring
The shortest valid submission for each language wins, this is code-golf. Good luck and have fun!
Sandbox for those who can see deleted posts.