Skip to content

Instantly share code, notes, and snippets.

@kunalbhatt
Created October 3, 2012 21:03
Show Gist options
  • Select an option

  • Save kunalbhatt/3829838 to your computer and use it in GitHub Desktop.

Select an option

Save kunalbhatt/3829838 to your computer and use it in GitHub Desktop.
Pig_latin tumblr
# Solution for Challenge: Implement from Pseudocode. Started 2012-10-02T04:28:05+00:00
#Iteration One
def pig_latin
vowels = [ 'a', 'e', 'i', 'o', 'u' ]
puts "Please enter word to be translated:"
word = gets.chomp
split_word = word.chars.to_a
if vowels.include?(split_word[0])
psuedo_vowel = word
puts psuedo_vowel
else
while !vowels.include?(split_word[0])
#this was the hardest part of the exercise, because it was very obvious what needed to be done. But to program it using ruby was tough.
first_char = split_word.shift
split_word << first_char
end
pseudo_cons = split_word + ['a', 'y']
puts pseudo_cons.join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment