Created
February 10, 2016 06:18
-
-
Save samuels410/bdcb663b6d8d1e5f05f0 to your computer and use it in GitHub Desktop.
Fiz buzz
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