Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Goat Latin

XPChallenge Points: 10
levelLevel: Easy

You are given a sentence consisting of words separated by spaces.
Your task is to transform the sentence into Goat Latin, a playful language transformation defined by the following rules:
1. If a word begins with a vowel (a, e, i, o, u, case-insensitive), append "ma" to the end of the word.
o Example: "apple" → "applema"
2. If a word begins with a consonant, remove its first letter, move it to the end, and then append "ma".
o Example: "goat" → "oatgma"
3. For each word, add an increasing number of 'a' characters to the end of the word — one 'a' for the first word, two 'a's for the second, and so on.
Finally, return the transformed sentence after applying all the above rules.

Example 1:

Input: sentence = "Amazing elephants run fast"

Output: "Amazingmaa elephantsmaaa unrmaaaa astfmaaaaa"

Example 2:

Input: sentence = "We love Python programming"

Output: "eWmaa ovelmaaa ythonPmaaaa rogrammingpmaaaaa"

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result