Problem 518. English to Pig Latin Translator
Pig latin is a faux-language based off of English. The rules are as follows (excerpted from the wikipedia entry for Pig Latin):
1. In words that begin with consonant sounds, the initial consonant or consonant cluster is moved to the end of the word, and "ay" is added, as in the following examples:
- happy → appy-hay
- question → estion-quay
2. In words that begin with vowels, the syllable "ay" is simply added to the end of the word.
- another → another-ay
- about → about-ay
A hyphen is sometimes used to facilitate translation back into English. Ayspray, for instance, is ambiguous, but ay-spray means "spray" whereas ays-pray means "prays."
Given a string in english (may be multiple words), produce the Pig Latin version.
Solution Stats
Problem Comments
-
3 Comments
The test suite has been rearranged to make it easier to understand what is being asked for.
Please check the test 1 and test 3. Shouldn'1 the test 1 solution be uestion-qay as compared to nix as ix-nay...
quidquid agis, prudenter agas, et respice finem!
Solution Comments
Show commentsProblem Recent Solvers147
Suggested Problems
-
4449 Solvers
-
Sort a list of complex numbers based on far they are from the origin.
5603 Solvers
-
1287 Solvers
-
Project Euler: Problem 10, Sum of Primes
1691 Solvers
-
The sum of the numbers in the vector
589 Solvers
More from this Author55
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!