Решение на Втора задача от Ивайло Бъчваров
Обратно към всички решения
Към профила на Ивайло Бъчваров
Резултати
- 3 точки от тестове
- 1 отнета точка
- 2 точки общо
- 10 успешни тест(а)
- 10 неуспешни тест(а)
Код
Лог от изпълнението
...F.F......FFFFFFFF
Failures:
1) #grow grows snake up/right/left/down
Failure/Error: expect(grow(snake, [1, 0])).to eq([[2, 2], [2, 3], [2, 4], [2, 5], [3, 5]])
expected: [[2, 2], [2, 3], [2, 4], [2, 5], [3, 5]]
got: [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 6]]
(compared using ==)
# /tmp/d20151026-15631-1137fjy/spec.rb:27:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) #grow does not mutate the given arguments
Failure/Error: expect { grow(snake, direction) }.not_to change { snake }
result should not have changed, but did change from [[2, 2], [2, 3], [2, 4], [2, 5]] to [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6]]
# /tmp/d20151026-15631-1137fjy/spec.rb:38:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) #obstacle_ahead? returns true if snake body ahead
Failure/Error: obstacle_ahead?([[5, 5], [4, 5], [4, 4], [5, 4]], [0, 1], dimensions)
ArgumentError:
comparison of Fixnum with nil failed
# /tmp/d20151026-15631-1137fjy/solution.rb:7:in `between?'
# /tmp/d20151026-15631-1137fjy/solution.rb:7:in `point_inside?'
# /tmp/d20151026-15631-1137fjy/solution.rb:28:in `obstacle_ahead?'
# /tmp/d20151026-15631-1137fjy/spec.rb:84:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) #obstacle_ahead? returns true if wall ahead
Failure/Error: expect(obstacle_ahead?([[8, 8], [8, 9]], [0, 1], dimensions)).to eq true
ArgumentError:
comparison of Fixnum with nil failed
# /tmp/d20151026-15631-1137fjy/solution.rb:7:in `between?'
# /tmp/d20151026-15631-1137fjy/solution.rb:7:in `point_inside?'
# /tmp/d20151026-15631-1137fjy/solution.rb:28:in `obstacle_ahead?'
# /tmp/d20151026-15631-1137fjy/spec.rb:89:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) #obstacle_ahead? returns false if no obstacle ahead
Failure/Error: expect(obstacle_ahead?([[3, 4], [3, 5]], [0, 1], dimensions)).to eq false
ArgumentError:
comparison of Fixnum with nil failed
# /tmp/d20151026-15631-1137fjy/solution.rb:7:in `between?'
# /tmp/d20151026-15631-1137fjy/solution.rb:7:in `point_inside?'
# /tmp/d20151026-15631-1137fjy/solution.rb:28:in `obstacle_ahead?'
# /tmp/d20151026-15631-1137fjy/spec.rb:93:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
6) #obstacle_ahead? does not mutate the given arguments
Failure/Error: expect { obstacle_ahead?(snake, direction, dimensions) }.not_to change { snake }
ArgumentError:
comparison of Fixnum with nil failed
# /tmp/d20151026-15631-1137fjy/solution.rb:7:in `between?'
# /tmp/d20151026-15631-1137fjy/solution.rb:7:in `point_inside?'
# /tmp/d20151026-15631-1137fjy/solution.rb:28:in `obstacle_ahead?'
# /tmp/d20151026-15631-1137fjy/spec.rb:99:in `block (3 levels) in <top (required)>'
# /tmp/d20151026-15631-1137fjy/spec.rb:99:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
7) #danger? returns true if obstacle in one turn
Failure/Error: expect(danger?([[7, 6], [8, 6], [9, 6]], [1, 0], dimensions)).to eq true
NoMethodError:
undefined method `obstacle_ahead' for #<RSpec::Core::ExampleGroup::Nested_5:0x007fd1a10e6f58>
# /tmp/d20151026-15631-1137fjy/solution.rb:33:in `danger?'
# /tmp/d20151026-15631-1137fjy/spec.rb:109:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
8) #danger? returns true if obstacle in two turns
Failure/Error: expect(danger?([[6, 6], [7, 6], [8, 6]], [1, 0], dimensions)).to eq true
NoMethodError:
undefined method `obstacle_ahead' for #<RSpec::Core::ExampleGroup::Nested_5:0x007fd1a10e50e0>
# /tmp/d20151026-15631-1137fjy/solution.rb:33:in `danger?'
# /tmp/d20151026-15631-1137fjy/spec.rb:113:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
9) #danger? returns false if obstacle in three turns
Failure/Error: expect(danger?([[5, 6], [6, 6], [7, 6]], [1, 0], dimensions)).to eq false
NoMethodError:
undefined method `obstacle_ahead' for #<RSpec::Core::ExampleGroup::Nested_5:0x007fd1a10de808>
# /tmp/d20151026-15631-1137fjy/solution.rb:33:in `danger?'
# /tmp/d20151026-15631-1137fjy/spec.rb:117:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
10) #danger? does not mutate the given arguments
Failure/Error: expect { danger?(snake, direction, dimensions) }.not_to change { snake }
NoMethodError:
undefined method `obstacle_ahead' for #<RSpec::Core::ExampleGroup::Nested_5:0x007fd1a10dc0a8>
# /tmp/d20151026-15631-1137fjy/solution.rb:33:in `danger?'
# /tmp/d20151026-15631-1137fjy/spec.rb:123:in `block (3 levels) in <top (required)>'
# /tmp/d20151026-15631-1137fjy/spec.rb:123:in `block (2 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01752 seconds
20 examples, 10 failures
Failed examples:
rspec /tmp/d20151026-15631-1137fjy/spec.rb:25 # #grow grows snake up/right/left/down
rspec /tmp/d20151026-15631-1137fjy/spec.rb:36 # #grow does not mutate the given arguments
rspec /tmp/d20151026-15631-1137fjy/spec.rb:82 # #obstacle_ahead? returns true if snake body ahead
rspec /tmp/d20151026-15631-1137fjy/spec.rb:88 # #obstacle_ahead? returns true if wall ahead
rspec /tmp/d20151026-15631-1137fjy/spec.rb:92 # #obstacle_ahead? returns false if no obstacle ahead
rspec /tmp/d20151026-15631-1137fjy/spec.rb:96 # #obstacle_ahead? does not mutate the given arguments
rspec /tmp/d20151026-15631-1137fjy/spec.rb:108 # #danger? returns true if obstacle in one turn
rspec /tmp/d20151026-15631-1137fjy/spec.rb:112 # #danger? returns true if obstacle in two turns
rspec /tmp/d20151026-15631-1137fjy/spec.rb:116 # #danger? returns false if obstacle in three turns
rspec /tmp/d20151026-15631-1137fjy/spec.rb:120 # #danger? does not mutate the given arguments
История (3 версии и 2 коментара)
Ивайло обнови решението на 19.10.2015 17:26 (преди над 9 години)
Ивайло обнови решението на 19.10.2015 17:28 (преди над 9 години)
Ивайло обнови решението на 19.10.2015 17:29 (преди над 9 години)