Skip to content

Instantly share code, notes, and snippets.

@jpowell
Created November 5, 2013 21:08
Show Gist options
  • Save jpowell/7326356 to your computer and use it in GitHub Desktop.
Save jpowell/7326356 to your computer and use it in GitHub Desktop.
FizzBuzz
SPECIAL_MODS = [[3, 'Fizz'], [5, 'Buzz']]
(1..100).each do |i|
output = SPECIAL_MODS.reduce([]) { |a, (n, s)| a.push(s) if i % n == 0; a }
puts output.empty? ? i : output.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment