Skip to content

Instantly share code, notes, and snippets.

@ccuadrado
Created April 28, 2015 15:56
Show Gist options
  • Save ccuadrado/288c5701ae566e52dfb8 to your computer and use it in GitHub Desktop.
Save ccuadrado/288c5701ae566e52dfb8 to your computer and use it in GitHub Desktop.
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