Skip to content

Instantly share code, notes, and snippets.

@mrb
Forked from JEG2/fizzbuzz.rb
Created August 1, 2012 21:18
Show Gist options
  • Select an option

  • Save mrb/3230825 to your computer and use it in GitHub Desktop.

Select an option

Save mrb/3230825 to your computer and use it in GitHub Desktop.

Revisions

  1. mrb revised this gist Aug 1, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions fizzbuzz.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    fizz = [nil, nil, "Fizz"].cycle
    buzz = [nil, nil, nil, nil, "Buzz"].cycle
    fizz = [nil, nil, "Fizz"].cycle.take(100)
    buzz = [nil, nil, nil, nil, "Buzz"].cycle.take(100)
    numbers = 1..100

    numbers.zip(fizz, buzz) do |n, f, b|
  2. @JEG2 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