-
-
Save gavinheavyside/3879345 to your computer and use it in GitHub Desktop.
Writing FizzBuzz without modulus division or 'if'
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
fizz = [nil, nil, "Fizz"].cycle | |
buzz = [nil, nil, nil, nil, "Buzz"].cycle | |
(1..100).zip(fizz, buzz) do |num, *fb| | |
puts fb.compact.reduce(:+) || num | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment