Skip to content

Instantly share code, notes, and snippets.

@JEG2
Created August 1, 2012 21:07

Revisions

  1. JEG2 created this gist Aug 1, 2012.
    8 changes: 8 additions & 0 deletions fizzbuzz.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    fizz = [nil, nil, "Fizz"].cycle
    buzz = [nil, nil, nil, nil, "Buzz"].cycle
    numbers = 1..100

    numbers.zip(fizz, buzz) do |n, f, b|
    fizzbuzz = [f, b].join
    puts(fizzbuzz.empty? ? n : fizzbuzz)
    end