Created
October 3, 2012 21:03
-
-
Save kunalbhatt/3829838 to your computer and use it in GitHub Desktop.
Pig_latin tumblr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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