You are given a `sentence` of words separated by single spaces, each made of lowercase and uppercase letters. Convert it to Goat Latin: if a word starts with a vowel (`a`, `e`, `i`, `o`, `u`, either case), append `"ma"`. Otherwise move its first letter to the end, then append `"ma"`. Finally append one `a` per word index, starting at 1: the first word gets `"a"`, the second `"aa"`, and so on. Return the converted sentence.
You are given a sentence of words separated by single spaces, each made of lowercase and uppercase letters. Convert it to Goat Latin: if a word starts with a vowel (a, e, i, o, u, either case), append "ma". Otherwise move its first letter to the end, then append "ma". Finally append one a per word index, starting at 1: the first word gets "a", the second "aa", and so on. Return the converted sentence.
Example 1:
Input: {"sentence":"I speak Goat Latin"}
Output: Imaa peaksmaaa oatGmaaaa atinLmaaaaa
Constraints:
1≤sentence.length≤150
sentence consists of English letters and spaces.
sentence has no leading or trailing spaces.
All the words in sentence are separated by a single space.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"sentence":"I speak Goat Latin"}
sentence, split on spaces
1·I
2·speak
3·Goat
4·Latin
workbench
1 first letter2 move + ma3 + k × a
waiting for the first word
Split the sentence into 4 word(s). Each word gets the same three-step treatment: check the first letter, add "ma", then add one 'a' per position.