Решение на Първа задача от Борислава Аладжова
Обратно към всички решения
Към профила на Борислава Аладжова
Резултати
- 0 точки от тестове
- 0 бонус точки
- 0 точки общо
- 0 успешни тест(а)
- 8 неуспешни тест(а)
Код
Лог от изпълнението
[1, 2, :fizz, 4, :buzz, :fizz, 7, 8, :fizz, :buzz, 11, :fizz, 13, 14, :fizz, :buzz, :fizzbuzz]FF[1, 2, :fizz, 4, :buzz, :fizz, 7, 8, :fizz, :buzz, 11, :fizz, 13, 14, :fizz, :buzz, :fizzbuzz, 16, 17, :fizz, 19, :buzz, :fizz, 22, 23, :fizz, :buzz, 26, :fizz, 28, 29, :fizz, :buzz, :fizzbuzz, 31, 32, :fizz, 34, :buzz, :fizz, 37, 38, :fizz, :buzz, 41, :fizz, 43, 44, :fizz, :buzz, :fizzbuzz, 46, 47, :fizz, 49, :buzz, :fizz, 52, 53, :fizz, :buzz, 56, :fizz, 58, 59, :fizz, :buzz, :fizzbuzz, 61, 62, :fizz, 64, :buzz, :fizz, 67, 68, :fizz, :buzz, 71, :fizz, 73, 74, :fizz, :buzz, :fizzbuzz, 76, 77, :fizz, 79, :buzz, :fizz, 82, 83, :fizz, :buzz, 86, :fizz, 88, 89, :fizz, :buzz, :fizzbuzz, 91, 92, :fizz, 94, :buzz, :fizz, 97, 98, :fizz, :buzz]F[:buzz, 11, :fizz, 13, 14, :fizz, :buzz, :fizzbuzz, 16]FFFFF
Failures:
1) Integer#prime_divisors can partition a simple number
Failure/Error: 10.prime_divisors.should eq [2, 5]
NoMethodError:
undefined method `prime_divisors' for 10:Fixnum
# /tmp/d20130307-6960-po9936/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]
NoMethodError:
undefined method `prime_divisors' for -10:Fixnum
# /tmp/d20130307-6960-po9936/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 [
expected: [1, 2, :fizz, 4, :buzz, :fizz, 7, 8, :fizz, :buzz, 11, :fizz, 13, 14, :fizzbuzz, 16, 17, :fizz, 19, :buzz, :fizz, 22, 23, :fizz, :buzz, 26, :fizz, 28, 29, :fizzbuzz, 31, 32, :fizz, 34, :buzz, :fizz, 37, 38, :fizz, :buzz, 41, :fizz, 43, 44, :fizzbuzz, 46, 47, :fizz, 49, :buzz, :fizz, 52, 53, :fizz, :buzz, 56, :fizz, 58, 59, :fizzbuzz, 61, 62, :fizz, 64, :buzz, :fizz, 67, 68, :fizz, :buzz, 71, :fizz, 73, 74, :fizzbuzz, 76, 77, :fizz, 79, :buzz, :fizz, 82, 83, :fizz, :buzz, 86, :fizz, 88, 89, :fizzbuzz, 91, 92, :fizz, 94, :buzz, :fizz, 97, 98, :fizz, :buzz]
got: nil
(compared using ==)
# /tmp/d20130307-6960-po9936/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]
expected: [:buzz, 11, :fizz, 13, 14, :fizzbuzz, 16]
got: nil
(compared using ==)
# /tmp/d20130307-6960-po9936/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-po9936/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-po9936/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-po9936/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-po9936/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.00849 seconds
8 examples, 8 failures
Failed examples:
rspec /tmp/d20130307-6960-po9936/spec.rb:2 # Integer#prime_divisors can partition a simple number
rspec /tmp/d20130307-6960-po9936/spec.rb:10 # Integer#prime_divisors works with negative numbers
rspec /tmp/d20130307-6960-po9936/spec.rb:17 # Range#fizzbuzz it works with the first 100 numbers
rspec /tmp/d20130307-6960-po9936/spec.rb:32 # Range#fizzbuzz works with tricky ranges
rspec /tmp/d20130307-6960-po9936/spec.rb:40 # Hash#group_values maps each value to an array of keys
rspec /tmp/d20130307-6960-po9936/spec.rb:44 # Hash#group_values takes repetitions into account
rspec /tmp/d20130307-6960-po9936/spec.rb:50 # Array#densities maps each element to the number of occurences in the original array
rspec /tmp/d20130307-6960-po9936/spec.rb:56 # Array#densities maps each element to the number of occurences in the original array (again)
История (1 версия и 1 коментар)
Борислава обнови решението на 15.10.2012 09:38 (преди около 12 години)