# FizzBuzz (#126) \[SOLUTION\]

**URL:** <https://www.ruby-forum.com/t/fizzbuzz-126-solution/105848>\
**Category:** Ruby\
**Created:** [June 3, 2007, 7:32pm UTC](https://www.ruby-forum.com/t/fizzbuzz-126-solution/105848 "2007-06-03T19:32:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug\_meyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@doug\_meyer](https://www.ruby-forum.com/u/doug_meyer)\
**Post date:** [June 3, 2007, 7:32pm UTC](https://www.ruby-forum.com/t/fizzbuzz-126-solution/105848/1 "2007-06-03T19:32:38Z")

</div>

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())}
