about | help | code help+videos | done | prefs |
string_toPigLatin
Given a String str, convert it into Pig Latin. Let's use these rules: 1. If a word starts with a consonant and then a vowel, put the first letter of the word at the end of the word and add "ay." Example: Happy = appyh + ay = appyhay 2. If a word starts with two consonants, move the two consonants to the end of the word and add "ay." Example: Child = Ildch + ay = Ildchay 3. If a word starts with a vowel, add the word "way" at the end of the word. Example: Awesome = Awesome + way = Awesomeway 4. If a word is only one letter, then just add "way" to the end. Example: i = i + way = iway string_toPigLatin("pig latin") → "igpay atinlay" string_toPigLatin("i love to code") → "iway ovelay otay odecay" string_toPigLatin("strings are my favorite topic") → "ringsstay areway myay avoritefay opictay" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy