Skip to content

Instantly share code, notes, and snippets.

@mtowers
Last active November 3, 2017 16:07
Show Gist options
  • Save mtowers/a54e16db647abcc02df73505812d9915 to your computer and use it in GitHub Desktop.
Save mtowers/a54e16db647abcc02df73505812d9915 to your computer and use it in GitHub Desktop.
FizzBuzz in Ruby
(1..100).each do |i|
out = { fizz: 3, buzz: 5 }.map do |k, v|
k if 0 == i % v
end.compact.join('')
puts "#{i}: #{out}" unless out.empty?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment