Created
August 8, 2017 10:54
-
-
Save basiszwo/94416e86c24390706e6c0f35adb90325 to your computer and use it in GitHub Desktop.
FizzBuzz Implementation
This file contains hidden or 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 = ["", "", "Fizz"].lazy.cycle | |
buzz = ["", "", "", "", "Buzz"].lazy.cycle | |
pattern = fizz.zip(buzz).map(&:join) | |
p pattern.take(15).to_a.join(", ") | |
numbers = (1..Float::INFINITY).lazy.map(&:to_s) | |
fizzbuzz = numbers.zip(pattern).map(&:max) | |
puts fizzbuzz.take(100).to_a.join(", ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment