Решение на Първа задача от Магдалена Патронска
Обратно към всички решения
Към профила на Магдалена Патронска
Резултати
- 0 точки от тестове
- 1 отнета точка
- 0 точки общо
- 0 успешни тест(а)
- 8 неуспешни тест(а)
Код
Лог от изпълнението
FFFFFFFF
Failures:
1) Integer#prime_divisors can partition a simple number
Failure/Error: 10.prime_divisors.should eq [2, 5]
ArgumentError:
wrong number of arguments (0 for 1)
# /tmp/d20130307-6960-1p86qk0/solution.rb:3:in `prime_divisors'
# /tmp/d20130307-6960-1p86qk0/spec.rb:3:in `block (2 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) Integer#prime_divisors works with negative numbers
Failure/Error: (-10).prime_divisors.should eq [2, 5]
ArgumentError:
wrong number of arguments (0 for 1)
# /tmp/d20130307-6960-1p86qk0/solution.rb:3:in `prime_divisors'
# /tmp/d20130307-6960-1p86qk0/spec.rb:11:in `block (2 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) Range#fizzbuzz it works with the first 100 numbers
Failure/Error: (1..100).fizzbuzz.should eq [
NoMethodError:
undefined method `fizzbuzz' for 1..100:Range
# /tmp/d20130307-6960-1p86qk0/spec.rb:18:in `block (2 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) Range#fizzbuzz works with tricky ranges
Failure/Error: (10...17).fizzbuzz.should eq [:buzz, 11, :fizz, 13, 14, :fizzbuzz, 16]
NoMethodError:
undefined method `fizzbuzz' for 10...17:Range
# /tmp/d20130307-6960-1p86qk0/spec.rb:33:in `block (2 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) Hash#group_values maps each value to an array of keys
Failure/Error: {a: 1}.group_values.should eq 1 => [:a]
NoMethodError:
undefined method `group_values' for {:a=>1}:Hash
# /tmp/d20130307-6960-1p86qk0/spec.rb:41:in `block (2 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) Hash#group_values takes repetitions into account
Failure/Error: {a: 1, b: 2, c: 1}.group_values.should eq 1 => [:a, :c], 2 => [:b]
NoMethodError:
undefined method `group_values' for {:a=>1, :b=>2, :c=>1}:Hash
# /tmp/d20130307-6960-1p86qk0/spec.rb:45:in `block (2 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) Array#densities maps each element to the number of occurences in the original array
Failure/Error: [:a, :b, :c].densities.should eq [1, 1, 1]
NoMethodError:
undefined method `densities' for [:a, :b, :c]:Array
# /tmp/d20130307-6960-1p86qk0/spec.rb:51:in `block (2 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) Array#densities maps each element to the number of occurences in the original array (again)
Failure/Error: [].densities.should eq []
NoMethodError:
undefined method `densities' for []:Array
# /tmp/d20130307-6960-1p86qk0/spec.rb:57:in `block (2 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.00594 seconds
8 examples, 8 failures
Failed examples:
rspec /tmp/d20130307-6960-1p86qk0/spec.rb:2 # Integer#prime_divisors can partition a simple number
rspec /tmp/d20130307-6960-1p86qk0/spec.rb:10 # Integer#prime_divisors works with negative numbers
rspec /tmp/d20130307-6960-1p86qk0/spec.rb:17 # Range#fizzbuzz it works with the first 100 numbers
rspec /tmp/d20130307-6960-1p86qk0/spec.rb:32 # Range#fizzbuzz works with tricky ranges
rspec /tmp/d20130307-6960-1p86qk0/spec.rb:40 # Hash#group_values maps each value to an array of keys
rspec /tmp/d20130307-6960-1p86qk0/spec.rb:44 # Hash#group_values takes repetitions into account
rspec /tmp/d20130307-6960-1p86qk0/spec.rb:50 # Array#densities maps each element to the number of occurences in the original array
rspec /tmp/d20130307-6960-1p86qk0/spec.rb:56 # Array#densities maps each element to the number of occurences in the original array (again)
История (1 версия и 1 коментар)
Магдалена обнови решението на 15.10.2012 07:46 (преди около 12 години)