Решение на Първа задача от Иван Иванов
Обратно към всички решения
Към профила на Иван Иванов
Резултати
- 3 точки от тестове
- 0 бонус точки
- 3 точки общо
- 7 успешни тест(а)
- 7 неуспешни тест(а)
Код
Лог от изпълнението
F..FF.FF..F.F.
Failures:
1) Integer#prime? checks if a number is prime
Failure/Error: -13.prime?.should eq false
Math::DomainError:
Numerical argument is out of domain - "sqrt"
# /tmp/d20131023-4395-yjeruf/solution.rb:4:in `sqrt'
# /tmp/d20131023-4395-yjeruf/solution.rb:4:in `prime?'
# /tmp/d20131023-4395-yjeruf/spec.rb:3: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) Integer#harmonic returns the n-th harmonic number
Failure/Error: 10.harmonic.should eq 7381/2520r
expected: (7381/2520)
got: (11/2)
(compared using ==)
# /tmp/d20131023-4395-yjeruf/spec.rb:37: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) Integer#digits constructs an array containing the digits of a number
Failure/Error: 0.digits.should eq [0]
expected: [0]
got: []
(compared using ==)
# /tmp/d20131023-4395-yjeruf/spec.rb:44: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) Array#frequencies returns a map from distinct items to the number of times they appear
Failure/Error: [:a, :a, :a].frequencies.should == { :a => 3 }
NoMethodError:
undefined method `+' for nil:NilClass
# /tmp/d20131023-4395-yjeruf/solution.rb:43:in `block in frequencies'
# /tmp/d20131023-4395-yjeruf/solution.rb:43:in `each'
# /tmp/d20131023-4395-yjeruf/solution.rb:43:in `frequencies'
# /tmp/d20131023-4395-yjeruf/spec.rb:60: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) Array#frequencies doesn't change the array
Failure/Error: expect { array.frequencies }.to_not change { array }
NoMethodError:
undefined method `+' for nil:NilClass
# /tmp/d20131023-4395-yjeruf/solution.rb:43:in `block in frequencies'
# /tmp/d20131023-4395-yjeruf/solution.rb:43:in `each'
# /tmp/d20131023-4395-yjeruf/solution.rb:43:in `frequencies'
# /tmp/d20131023-4395-yjeruf/spec.rb:68:in `block (3 levels) in <top (required)>'
# /tmp/d20131023-4395-yjeruf/spec.rb:68: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) Array#drop_every drops every n-th element from an array.
Failure/Error: (1..10).to_a.drop_every(3).should eq [1, 2, 4, 5, 7, 8, 10]
expected: [1, 2, 4, 5, 7, 8, 10]
got: [1, 4, 7, 10]
(compared using ==)
# /tmp/d20131023-4395-yjeruf/spec.rb:91: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) Array#combine_with combines two arrays by alternatingly taking elements
Failure/Error: [:a, :b, :c].combine_with([1, nil, 3]).should eq [:a, 1, :b, nil, :c, 3]
expected: [:a, 1, :b, nil, :c, 3]
got: [:a, 1, :b, :c, 3]
(compared using ==)
# /tmp/d20131023-4395-yjeruf/spec.rb:110: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.01728 seconds
14 examples, 7 failures
Failed examples:
rspec /tmp/d20131023-4395-yjeruf/spec.rb:2 # Integer#prime? checks if a number is prime
rspec /tmp/d20131023-4395-yjeruf/spec.rb:34 # Integer#harmonic returns the n-th harmonic number
rspec /tmp/d20131023-4395-yjeruf/spec.rb:43 # Integer#digits constructs an array containing the digits of a number
rspec /tmp/d20131023-4395-yjeruf/spec.rb:58 # Array#frequencies returns a map from distinct items to the number of times they appear
rspec /tmp/d20131023-4395-yjeruf/spec.rb:66 # Array#frequencies doesn't change the array
rspec /tmp/d20131023-4395-yjeruf/spec.rb:87 # Array#drop_every drops every n-th element from an array.
rspec /tmp/d20131023-4395-yjeruf/spec.rb:103 # Array#combine_with combines two arrays by alternatingly taking elements
История (2 версии и 0 коментара)
Иван обнови решението на 16.10.2013 01:44 (преди около 11 години)
Иван обнови решението на 16.10.2013 13:25 (преди около 11 години)