Skip to content

Commit

Permalink
Fibonacci hole
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmcdonough committed May 3, 2011
1 parent 0dba383 commit f0cc75c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/golf_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + "/spec_helper"

describe "Golf" do

describe ".hole1" do
it "should multiply the numbers in an array" do
Golf.hole1([1,2,3,4]).should == 24
Expand All @@ -9,6 +10,7 @@
Golf.hole1([5,2,10,6]).should == 600
end
end

describe ".hole6" do
it "should play fizzbuzz to 3, where multiples of 3 are 'fizz'" do
Golf.hole6(3).should == [1,2,"fizz"]
Expand All @@ -23,5 +25,18 @@
Golf.hole6(30).should == [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"]
end
end

describe ".hole8" do
it "should give the first N numbers of the fibonacci sequence" do
Golf.hole8(5).should == [1,1,2,3,5]
end
it "should give the first 9 numbers" do
Golf.hole8(9).should == [1,1,2,3,5,8,13,21,34]
end
it "should give the first 15 numbers" do
Golf.hole8(15).should == [1,1,2,3,5,8,13,21,34,55,89,144,233,377,610]
end
end

end

0 comments on commit f0cc75c

Please sign in to comment.