Created
April 28, 2015 15:56
-
-
Save ccuadrado/288c5701ae566e52dfb8 to your computer and use it in GitHub Desktop.
This file contains 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 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