Skip to content

Instantly share code, notes, and snippets.

@sgottlieb
sgottlieb / word_count.rb
Created October 29, 2012 22:08
Word count with Ruby
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
@sgottlieb
sgottlieb / Ruby Basics Lesson
Created September 24, 2012 23:06
pig latin and numbers to words excercises
#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"