Edited at

怠惰なFizzBuzzが面白かったので自分も怠惰なFizzBuzz書いてみた

More than 1 year has passed since last update.

怠惰なFizzBuzzが面白かったので パクリました 真似して書いてみました。

https://qiita.com/QUANON/items/c77c22b910651b54fe24

numbers = 1.step

fizzes = [nil, nil, "Fizz"].cycle
buzzes = [nil, nil, nil, nil, "Buzz"].cycle

numbers
.lazy
.zip(fizzes, buzzes)
.map { |n, *yells| yells.any? ? yells.join : n }
.take(30)
.each(&method(:puts))

1

2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz