Решение на Трета задача от Георги Стефанов
Обратно към всички решения
Към профила на Георги Стефанов
Резултати
- 5 точки от тестове
- 1 отнета точка
- 4 точки общо
- 15 успешни тест(а)
- 5 неуспешни тест(а)
Код
Лог от изпълнението
..FF..F......F.....F
Failures:
1) Fifth task RationalSequence can calculate the first 28 rational numbers
Failure/Error: expect(RationalSequence.new(28).to_a).to eq %w(
Timeout::Error:
execution expired
# /tmp/d20151111-27349-g91bae/solution.rb:26:in `increasing_numerator'
# /tmp/d20151111-27349-g91bae/solution.rb:47:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `block in initialize'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `upto'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `each'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `map'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `initialize'
# /tmp/d20151111-27349-g91bae/spec.rb:12:in `new'
# /tmp/d20151111-27349-g91bae/spec.rb:12:in `block (3 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) Fifth task RationalSequence is properly enumerable
Failure/Error: ones = RationalSequence.new(28).select { |r| r.numerator == 1 }
Timeout::Error:
execution expired
# /tmp/d20151111-27349-g91bae/solution.rb:54:in `convert'
# /tmp/d20151111-27349-g91bae/solution.rb:54:in `Rational'
# /tmp/d20151111-27349-g91bae/solution.rb:54:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `block in initialize'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `upto'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `each'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `map'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `initialize'
# /tmp/d20151111-27349-g91bae/spec.rb:19:in `new'
# /tmp/d20151111-27349-g91bae/spec.rb:19:in `block (3 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) Fifth task FibonacciSequence can be used to calculate the Lucas numbers
Failure/Error: expect(FibonacciSequence.new(31, first: 2, second: 1).to_a).to eq [
Timeout::Error:
execution expired
# /tmp/d20151111-27349-g91bae/solution.rb:66:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:65:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:65:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:65:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:65:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:65:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:65:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:64:in `nth_fibonacci'
# /tmp/d20151111-27349-g91bae/solution.rb:89:in `block in initialize'
# /tmp/d20151111-27349-g91bae/solution.rb:89:in `upto'
# /tmp/d20151111-27349-g91bae/solution.rb:89:in `each'
# /tmp/d20151111-27349-g91bae/solution.rb:89:in `map'
# /tmp/d20151111-27349-g91bae/solution.rb:89:in `initialize'
# /tmp/d20151111-27349-g91bae/spec.rb:37:in `new'
# /tmp/d20151111-27349-g91bae/spec.rb:37:in `block (3 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) Fifth task DrunkenMathematician #meaningless can calculate for 42
Failure/Error: expect(DrunkenMathematician.meaningless(42)).to eq Rational(1, 11)
Timeout::Error:
execution expired
# /tmp/d20151111-27349-g91bae/solution.rb:54:in `Rational'
# /tmp/d20151111-27349-g91bae/solution.rb:54:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `block in initialize'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `upto'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `each'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `map'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `initialize'
# /tmp/d20151111-27349-g91bae/solution.rb:121:in `new'
# /tmp/d20151111-27349-g91bae/solution.rb:121:in `meaningless'
# /tmp/d20151111-27349-g91bae/spec.rb:82:in `block (4 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) Fifth task DrunkenMathematician #worthless can calculate for 15
Failure/Error: expect(DrunkenMathematician.worthless(15)).to eq %w(
Timeout::Error:
execution expired
# /tmp/d20151111-27349-g91bae/solution.rb:36:in `decreasing_numerator'
# /tmp/d20151111-27349-g91bae/solution.rb:50:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:44:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:43:in `rational_generator'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `block in initialize'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `upto'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `each'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `map'
# /tmp/d20151111-27349-g91bae/solution.rb:103:in `initialize'
# /tmp/d20151111-27349-g91bae/solution.rb:137:in `new'
# /tmp/d20151111-27349-g91bae/solution.rb:137:in `worthless'
# /tmp/d20151111-27349-g91bae/spec.rb:112:in `block (4 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 5.5 seconds
20 examples, 5 failures
Failed examples:
rspec /tmp/d20151111-27349-g91bae/spec.rb:11 # Fifth task RationalSequence can calculate the first 28 rational numbers
rspec /tmp/d20151111-27349-g91bae/spec.rb:18 # Fifth task RationalSequence is properly enumerable
rspec /tmp/d20151111-27349-g91bae/spec.rb:36 # Fifth task FibonacciSequence can be used to calculate the Lucas numbers
rspec /tmp/d20151111-27349-g91bae/spec.rb:81 # Fifth task DrunkenMathematician #meaningless can calculate for 42
rspec /tmp/d20151111-27349-g91bae/spec.rb:111 # Fifth task DrunkenMathematician #worthless can calculate for 15
История (3 версии и 1 коментар)
Георги обнови решението на 25.10.2015 00:13 (преди над 9 години)
Георги обнови решението на 25.10.2015 11:48 (преди над 9 години)
Георги обнови решението на 26.10.2015 10:23 (преди над 9 години)