Skip to content

Instantly share code, notes, and snippets.

@mikedao
Last active December 15, 2015 22:34
Show Gist options
  • Save mikedao/a7b67ee52f1df24476b9 to your computer and use it in GitHub Desktop.
Save mikedao/a7b67ee52f1df24476b9 to your computer and use it in GitHub Desktop.

Pig Latin Translator

You are to create a Pig Latin Translator that has a REPL that follows an interaction model similar to this.

Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an ay, or if a word begins with a vowel you just add way to the end. For example, pig becomes ig-pay, banana becomes anana-bay, and aadvark becomes aadvark-way.

> cat

at-cay

> apple

apple-way

>exit!

oodbye-gay!

Your translator should use a loop and continue to translate words until exit! is given to the translator, at which point it will tell you goodbye and then quit.

Bonus

Make it so that your translator will also detect words that are already in pig latin and translate them back into English.

> at-cay

cat

> apple-way

apple

>exit!

oodbye-gay!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment