Skip to content

Instantly share code, notes, and snippets.

@mjseaman
Created June 25, 2013 20:13
Show Gist options
  • Save mjseaman/5861943 to your computer and use it in GitHub Desktop.
Save mjseaman/5861943 to your computer and use it in GitHub Desktop.
def pig_latin_word(input)
index = input.split(//).index { |letter| letter[/[aeiouAEIOU]/] != nil }
(input + (input.slice!(0..(index-1))) + "ay").downcase
end
def pig_latin_phrase(input)
input.split(" ").map {|current_word| pig_latin_word(current_word)}.join(" ").capitalize
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment