Skip to content

Commit

Permalink
calculating the neighbours of 1,1
Browse files Browse the repository at this point in the history
  • Loading branch information
bishboria committed Mar 13, 2011
1 parent 3d22de4 commit b5d98d9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/2011_03_12_game_of_life.rb
@@ -0,0 +1,5 @@
def neighbours_of row, column
[[0,0],[0,1],[0,2],
[1,0],[1,2],
[2,0],[2,1],[2,2]]
end
33 changes: 32 additions & 1 deletion spec/2011_03_12_game_of_life_spec.rb
@@ -1 +1,32 @@
require 'spec_helper'
require 'spec_helper'

describe "Game of Life" do
context "Working out neighbours" do
context "a cell located at position 1,1" do
it "has a neighbour at 0,0" do
neighbours_of(1,1).should include([0,0])
end
it "has a neighbour at 0,1" do
neighbours_of(1,1).should include([0,1])
end
it "has a neighbour at 0,2" do
neighbours_of(1,1).should include([0,2])
end
it "has a neighbour at 1,0" do
neighbours_of(1,1).should include([1,0])
end
it "has a neighbour at 1,2" do
neighbours_of(1,1).should include([1,2])
end
it "has a neighbour at 2,0" do
neighbours_of(1,1).should include([2,0])
end
it "has a neighbour at 2,1" do
neighbours_of(1,1).should include([2,1])
end
it "has a neighbour at 2,2" do
neighbours_of(1,1).should include([2,2])
end
end
end
end

0 comments on commit b5d98d9

Please sign in to comment.