Skip to content

Instantly share code, notes, and snippets.

@kareemgrant
Last active August 29, 2015 14:18
Show Gist options
  • Save kareemgrant/c33495a220abef9411a7 to your computer and use it in GitHub Desktop.
Save kareemgrant/c33495a220abef9411a7 to your computer and use it in GitHub Desktop.
BE101 Session 1 Homework Answers
def america_phrase(phrase)
"#{phrase}; Only in America!"
end
puts "Enter a phrase"
input = gets.chomp
puts america_phrase(input)
def combine(array_one, array_two)
combination = {}
array_one.each_with_index do |key, index|
combination[key] = array_two[index]
end
combination
end
puts combine([:a, :b, :c], [1, 2, 3])
def fizzbuzz(num)
return "fizzbuzz" if (num % 3 == 0) && (num % 5 == 0)
return "fizz" if num % 3 == 0
return "buzz" if num % 5 == 0
num
end
(1..100).to_a.each {|n| puts fizzbuzz(n) }
def max(numbers)
numbers.sort.last
end
puts max([50, -9, 77, 91, 34])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment