Skip to content

Instantly share code, notes, and snippets.

@samuels410
Created February 10, 2016 06:18
Show Gist options
  • Save samuels410/bdcb663b6d8d1e5f05f0 to your computer and use it in GitHub Desktop.
Save samuels410/bdcb663b6d8d1e5f05f0 to your computer and use it in GitHub Desktop.
Fiz buzz
def fizzbuzz(range, triggers)
range.each do |i|
result = ''
triggers.each do |(text, divisor)|
result << text if i % divisor == 0
end
puts result == '' ? i : result
end
end
fizzbuzz(1..100, [
['Fizz', 3],
['Buzz', 5],
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment