This is one of those quizzes that is so easy, you have to find some
ridiculous way of solving it
First off, there is the correct way of coding: clear, concise, and
actually works
#!/usr/bin/env ruby
Douglas Meyer
(1…100).each do |number|
if number % 3 == 0 && number % 5 == 0
puts ‘FizzBuzz’
elsif number % 3 == 0
puts ‘Fizz’
elsif number % 5 == 0
puts ‘Buzz’
else
puts number
end
end
Then there is the solution I would NEVER give during an interview or
use in a application (unless I had tests, and I was the only one
programming the application). I think this is the first time I used
zip, also the |x,*y| makes me think of erlang, lol
#!/usr/bin/env ruby
Douglas Meyer
(1…100).zip((([nil]*2<<‘Fizz’)*34),([nil]*4<<‘Buzz’)*20){|x,*y| puts
(y.compact.empty? ? x : y.join())}