Skip to content

Instantly share code, notes, and snippets.

@jonvuri
jonvuri / pig_latin.rb
Created November 22, 2012 00:08
Pig Latin Refinement
def translate(pigstri)
vowels = [ "a", "e", "i", "o", "u", "y" ]
pigstri
.split(/ /, -1)
.map { |x|
first_vowel = x.chars.find_index { |x| vowels.include?(x) }
if vowels.include?(x[0])
x + "ay"
elsif x[0..1].include?("qu")
x[2..x.length] + x[0..1] + "ay"