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
def open_file(filename) | |
word_list = [] | |
aFile = File.open(filename, "r+") | |
aFile.each do |line| | |
list = line.split(" ") | |
list.each do |word| | |
word_list << word | |
end | |
end |
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
#pig latin | |
def translate(word) | |
vowels = ["a", "e", "i", "o", "u"] | |
if vowels.include?(word[0]) | |
return word <<"ay" | |
elsif word[0..2] =="sch" | |
return word[3..-1] <<word[0..2]<<"ay" | |
elsif vowels.include?(word[1]) == false | |
return word[2..-1] << word[0..1] <<"ay" |