← 返回 meta 的题目列表Goat Latin
类型:online_judge
meta
Given a string S, which consists of words separated by spaces, return a new string representing the conversion to "Goat Latin". The transformation rules are as follows:
If a word begins with a vowel, append "ma" to the end of the word. For example, the word "apple" becomes "applema".
If a word begins with a consonant, move the first letter to the end and then append "ma". For example, the word "goat" becomes "oatgma".
Add one letter 'a' to the end of each word per its index in the sentence, starting with 1. For example, the first word gets an 'a', the second word gets 'aa', and so on.
Return the final string after applying the conversions to every word in S.
Example:
Input: "I speak Goat Latin"
Output: "Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
Constraints
The input string will not exceed 150 characters.
The number of words in S is in the range [1, 150].
S contains only uppercase and lowercase letters and spaces.
Note that the output should preserve the spaces between words from the input.
Example
Input
I speak Goat Latin