Skip to content

Instantly share code, notes, and snippets.

@basiszwo
Created August 8, 2017 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basiszwo/94416e86c24390706e6c0f35adb90325 to your computer and use it in GitHub Desktop.
Save basiszwo/94416e86c24390706e6c0f35adb90325 to your computer and use it in GitHub Desktop.
FizzBuzz Implementation
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