Решение на Шеста задача от Татяна Тотева

Обратно към всички решения

Към профила на Татяна Тотева

Резултати

  • 3 точки от тестове
  • 0 бонус точки
  • 3 точки общо
  • 8 успешни тест(а)
  • 10 неуспешни тест(а)

Код

class GameOfLife
include Enumerable
class Board
def self.new(*board)
@board=board
end
def next_generation
new_board=Board.new
@board.each do |x, y|
end
end
end
end

Лог от изпълнението

......F..FFFFFFFFF

Failures:

  1) GameOfLife::Board GameOfLife::Board enumeration live cells count returns the number of live cells on a board
     Failure/Error: new_board([0, 0], [1, 1], [0, 0]).count.should eq 2
       
       expected: 2
            got: 3
       
       (compared using ==)
     # /tmp/d20111221-3114-16x800e/spec.rb:46:in `block (4 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) GameOfLife::Board evolution responds to next_generation
     Failure/Error: new_board.should respond_to(:next_generation)
       expected [] to respond to :next_generation
     # /tmp/d20111221-3114-16x800e/spec.rb:69:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) GameOfLife::Board evolution returns a new board
     Failure/Error: next_gen = board.next_generation
     NoMethodError:
       undefined method `next_generation' for []:Array
     # /tmp/d20111221-3114-16x800e/spec.rb:74:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) GameOfLife::Board GameOfLife::Board evolution rules kills cells in underpopulated areas
     Failure/Error: next_gen = board.next_generation
     NoMethodError:
       undefined method `next_generation' for [[1, 1]]:Array
     # /tmp/d20111221-3114-16x800e/spec.rb:86:in `block (4 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) GameOfLife::Board GameOfLife::Board evolution rules preserves stable cells
     Failure/Error: next_gen = board.next_generation
     NoMethodError:
       undefined method `next_generation' for [[0, 1], [1, 1], [2, 1], [1, 2]]:Array
     # /tmp/d20111221-3114-16x800e/spec.rb:100:in `block (4 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) GameOfLife::Board GameOfLife::Board evolution rules kills cells in overpopulated areas
     Failure/Error: next_gen = board.next_generation
     NoMethodError:
       undefined method `next_generation' for [[0, 1], [1, 1], [2, 1], [1, 2], [1, 0]]:Array
     # /tmp/d20111221-3114-16x800e/spec.rb:111:in `block (4 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) GameOfLife::Board GameOfLife::Board evolution rules sprouts new life when appropriate
     Failure/Error: board[1, 0].should be_false
       expected [] to be false
     # /tmp/d20111221-3114-16x800e/spec.rb:120:in `block (4 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) GameOfLife::Board GameOfLife::Board evolution rules evolves a formation correctly
     Failure/Error: next_gen = board.next_generation
     NoMethodError:
       undefined method `next_generation' for [[0, 1], [1, 1], [2, 1], [1, 2]]:Array
     # /tmp/d20111221-3114-16x800e/spec.rb:134:in `block (4 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) GameOfLife::Board GameOfLife::Board evolution rules oscilates the oscilators
     Failure/Error: board = board.next_generation
     NoMethodError:
       undefined method `next_generation' for [[0, 1], [1, 1], [2, 1]]:Array
     # /tmp/d20111221-3114-16x800e/spec.rb:147:in `block (5 levels) in <top (required)>'
     # /tmp/d20111221-3114-16x800e/spec.rb:142:in `times'
     # /tmp/d20111221-3114-16x800e/spec.rb:142:in `block (4 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) GameOfLife::Board GameOfLife::Board evolution rules keeps stable formations stable
     Failure/Error: board = board.next_generation
     NoMethodError:
       undefined method `next_generation' for [[0, 0], [1, 0], [0, 1], [1, 1]]:Array
     # /tmp/d20111221-3114-16x800e/spec.rb:159:in `block (6 levels) in <top (required)>'
     # /tmp/d20111221-3114-16x800e/spec.rb:158:in `times'
     # /tmp/d20111221-3114-16x800e/spec.rb:158:in `block (5 levels) in <top (required)>'
     # /tmp/d20111221-3114-16x800e/spec.rb:155:in `each'
     # /tmp/d20111221-3114-16x800e/spec.rb:155:in `block (4 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.32309 seconds
18 examples, 10 failures

Failed examples:

rspec /tmp/d20111221-3114-16x800e/spec.rb:43 # GameOfLife::Board GameOfLife::Board enumeration live cells count returns the number of live cells on a board
rspec /tmp/d20111221-3114-16x800e/spec.rb:68 # GameOfLife::Board evolution responds to next_generation
rspec /tmp/d20111221-3114-16x800e/spec.rb:72 # GameOfLife::Board evolution returns a new board
rspec /tmp/d20111221-3114-16x800e/spec.rb:81 # GameOfLife::Board GameOfLife::Board evolution rules kills cells in underpopulated areas
rspec /tmp/d20111221-3114-16x800e/spec.rb:95 # GameOfLife::Board GameOfLife::Board evolution rules preserves stable cells
rspec /tmp/d20111221-3114-16x800e/spec.rb:106 # GameOfLife::Board GameOfLife::Board evolution rules kills cells in overpopulated areas
rspec /tmp/d20111221-3114-16x800e/spec.rb:117 # GameOfLife::Board GameOfLife::Board evolution rules sprouts new life when appropriate
rspec /tmp/d20111221-3114-16x800e/spec.rb:129 # GameOfLife::Board GameOfLife::Board evolution rules evolves a formation correctly
rspec /tmp/d20111221-3114-16x800e/spec.rb:139 # GameOfLife::Board GameOfLife::Board evolution rules oscilates the oscilators
rspec /tmp/d20111221-3114-16x800e/spec.rb:151 # GameOfLife::Board GameOfLife::Board evolution rules keeps stable formations stable

История (1 версия и 0 коментара)

Татяна обнови решението на 20.12.2011 23:20 (преди над 8 години)

+class GameOfLife
+ include Enumerable
+
+ class Board
+ def self.new(*board)
+ @board=board
+ end
+
+ def next_generation
+ new_board=Board.new
+ @board.each do |x, y|
+
+ end
+
+ end
+
+
+ end
+end