Решение на Бонус задача: ArnoldC+- от Здравко Петров

Обратно към всички решения

Към профила на Здравко Петров

Резултати

  • 0 точки от тестове
  • 0 бонус точки
  • 0 точки общо
  • 1 успешни тест(а)
  • 28 неуспешни тест(а)

Код

class BasicObject
attr_accessor :its_showtime, :i_let_him_go, :get_up, :get_down, :youre_fired
attr_accessor :he_had_to_split, :you_have_been_terminated, :talk_to_the_hand
attr_accessor :get_to_the_chopper, :here_is_my_invitation, :enough_talk
attr_accessor :i_lied, :no_problemo, :you_are_not_you_you_are_me
attr_accessor :get_your_ass_to_mars, :you_have_no_respect_for_logic
attr_accessor :let_off_some_steam_bennet, :consider_that_a_divorce
attr_accessor :i_need_your_clothes_your_boots_and_your_motorcycle
attr_accessor :because_im_going_to_say_please, :bull_shit, :do_it_no
attr_accessor :listen_to_me_very_carefully, :knock_knock
attr_accessor :ill_be_back, :hasta_la_vista_baby, :give_these_people_air
def its_showtime
# TODO
end
def talk_to_the_hand(value)
puts value
end
def you_have_been_terminated
# TODO
end
end
module ArnoldCPM
def self.totally_recall(&block)
block.call
end
def self.printer=(*)
# TODO
end
end
ArnoldCPM.printer = Kernel
ArnoldCPM.totally_recall do
its_showtime
talk_to_the_hand 110_110
talk_to_the_hand 11_101_101
you_have_been_terminated
end

Лог от изпълнението

110110
11101101
.

FFFFFFFFFFFFFFFFFFFFFFFFFFFF

Failures:

  1) ArnoldCPM has true and false constants
     Failure/Error: expect(printer).to receive(:print).with(value_to_be_printed).ordered
       (Double "printer").print(0)
           expected: 1 time with arguments: (0)
           received: 0 times with arguments: (0)
     # /tmp/d20170103-15620-1s635ce/spec.rb:878:in `block in expect_execution'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  2) ArnoldCPM can assign variables
     Failure/Error: get_to_the_chopper _the_answer
     NameError:
       undefined local variable or method `_the_answer' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f61479780>
     # /tmp/d20170103-15620-1s635ce/spec.rb:35:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:33:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  3) ArnoldCPM can define and call functions with arguments
     Failure/Error: listen_to_me_very_carefully _printing_function
     NameError:
       undefined local variable or method `_printing_function' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f614bd610>
     # /tmp/d20170103-15620-1s635ce/spec.rb:476:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:475:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  4) ArnoldCPM can define and call functions with return value
     Failure/Error: listen_to_me_very_carefully _non_void_function
     NameError:
       undefined local variable or method `_non_void_function' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f612dd110>
     # /tmp/d20170103-15620-1s635ce/spec.rb:500:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:499:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  5) ArnoldCPM returns 0 by default
     Failure/Error: listen_to_me_very_carefully _return_no_argument
     NameError:
       undefined local variable or method `_return_no_argument' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f612d1a68>
     # /tmp/d20170103-15620-1s635ce/spec.rb:526:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:525:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  6) ArnoldCPM can take functions as arguments
     Failure/Error: listen_to_me_very_carefully _forty_two_printer
     NameError:
       undefined local variable or method `_forty_two_printer' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f612c65f0>
     # /tmp/d20170103-15620-1s635ce/spec.rb:557:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:556:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  7) ArnoldCPM can return functions
     Failure/Error: listen_to_me_very_carefully _function_generator
     NameError:
       undefined local variable or method `_function_generator' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f61fede18>
     # /tmp/d20170103-15620-1s635ce/spec.rb:594:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:593:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  8) ArnoldCPM defines new inner functions for each function invocation
     Failure/Error: listen_to_me_very_carefully _define_function
     NameError:
       undefined local variable or method `_define_function' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f61fd3298>
     # /tmp/d20170103-15620-1s635ce/spec.rb:626:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:625:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  9) ArnoldCPM supports basic recursion
     Failure/Error: listen_to_me_very_carefully _count
     NameError:
       undefined local variable or method `_count' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f61fc9d60>
     # /tmp/d20170103-15620-1s635ce/spec.rb:667:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:666:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  10) ArnoldCPM can calculate fibonacci(20) recursively
     Failure/Error: listen_to_me_very_carefully _fibonacci
     NameError:
       undefined local variable or method `_fibonacci' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f61fa3890>
     # /tmp/d20170103-15620-1s635ce/spec.rb:715:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:714:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  11) ArnoldCPM can use closures in very convoluted ways
     Failure/Error: listen_to_me_very_carefully _null
     NameError:
       undefined local variable or method `_null' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f1f61f89558>
     # /tmp/d20170103-15620-1s635ce/spec.rb:766:in `block (3 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:765:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  12) ArnoldCPM has algebra that can sum numbers
     Failure/Error: get_to_the_chopper _sum
     NameError:
       undefined local variable or method `_sum' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007f1f61f2f788>
     # /tmp/d20170103-15620-1s635ce/spec.rb:52:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:50:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  13) ArnoldCPM has algebra that can subtract numbers
     Failure/Error: get_to_the_chopper _difference
     NameError:
       undefined local variable or method `_difference' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007f1f61f24dd8>
     # /tmp/d20170103-15620-1s635ce/spec.rb:69:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:67:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  14) ArnoldCPM has algebra that can multiply numbers
     Failure/Error: get_to_the_chopper _product
     NameError:
       undefined local variable or method `_product' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007f1f61f1f478>
     # /tmp/d20170103-15620-1s635ce/spec.rb:86:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:84:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  15) ArnoldCPM has algebra that can divide numbers
     Failure/Error: get_to_the_chopper _quotient
     NameError:
       undefined local variable or method `_quotient' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007f1f61f0a258>
     # /tmp/d20170103-15620-1s635ce/spec.rb:103:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:101:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  16) ArnoldCPM has algebra that can calculate modulo
     Failure/Error: get_to_the_chopper _modulu
     NameError:
       undefined local variable or method `_modulu' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007f1f61ee3b08>
     # /tmp/d20170103-15620-1s635ce/spec.rb:120:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:118:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  17) ArnoldCPM has algebra that can chain multiple operations
     Failure/Error: get_to_the_chopper _result
     NameError:
       undefined local variable or method `_result' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007f1f61e8d488>
     # /tmp/d20170103-15620-1s635ce/spec.rb:138:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:136:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  18) ArnoldCPM has algebra that can use variables in calculations
     Failure/Error: get_to_the_chopper _x
     NameError:
       undefined local variable or method `_x' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007f1f61e82d80>
     # /tmp/d20170103-15620-1s635ce/spec.rb:163:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:161:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  19) ArnoldCPM has boolean arithmetic that given *or* returns truthy values if one of the operands is truthy
     Failure/Error: get_to_the_chopper _result
     NameError:
       undefined local variable or method `_result' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x007f1f61e788f8>
     # /tmp/d20170103-15620-1s635ce/spec.rb:194:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:192:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  20) ArnoldCPM has boolean arithmetic that given *or* returns falsy values if both operands are falsy
     Failure/Error: get_to_the_chopper _result
     NameError:
       undefined local variable or method `_result' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x007f1f61e6b888>
     # /tmp/d20170103-15620-1s635ce/spec.rb:225:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:223:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  21) ArnoldCPM has boolean arithmetic that given *or* between two truthy values returns the first one
     Failure/Error: get_to_the_chopper _result
     NameError:
       undefined local variable or method `_result' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x007f1f61e64ad8>
     # /tmp/d20170103-15620-1s635ce/spec.rb:242:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:240:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  22) ArnoldCPM has boolean arithmetic that given *and* returns falsy values if either operand is falsy
     Failure/Error: get_to_the_chopper _result
     NameError:
       undefined local variable or method `_result' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x007f1f61e5b2f8>
     # /tmp/d20170103-15620-1s635ce/spec.rb:263:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:261:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  23) ArnoldCPM has boolean arithmetic that given *and* between two truthy values returns the second one
     Failure/Error: get_to_the_chopper _result
     NameError:
       undefined local variable or method `_result' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x007f1f61e52f68>
     # /tmp/d20170103-15620-1s635ce/spec.rb:294:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:292:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  24) ArnoldCPM has boolean arithmetic that has the same precedence of *or* and *and* operations
     Failure/Error: get_to_the_chopper _result
     NameError:
       undefined local variable or method `_result' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x007f1f61e39ef0>
     # /tmp/d20170103-15620-1s635ce/spec.rb:311:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:309:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  25) ArnoldCPM has branching mechanism that can execute if statements
     Failure/Error: because_im_going_to_say_please no_problemo
     ArgumentError:
       wrong number of arguments (given 1, expected 0)
     # /tmp/d20170103-15620-1s635ce/spec.rb:336:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:334:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  26) ArnoldCPM has branching mechanism that can execute if-else statements
     Failure/Error: because_im_going_to_say_please no_problemo
     ArgumentError:
       wrong number of arguments (given 1, expected 0)
     # /tmp/d20170103-15620-1s635ce/spec.rb:363:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:361:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  27) ArnoldCPM has branching mechanism that can nest if-else statements
     Failure/Error: because_im_going_to_say_please no_problemo
     ArgumentError:
       wrong number of arguments (given 1, expected 0)
     # /tmp/d20170103-15620-1s635ce/spec.rb:410:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:408:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  28) ArnoldCPM has branching mechanism that considers functions truthy
     Failure/Error: listen_to_me_very_carefully _function
     NameError:
       undefined local variable or method `_function' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_3:0x007f1f61dbb078>
     # /tmp/d20170103-15620-1s635ce/spec.rb:452:in `block (4 levels) in <top (required)>'
     # /tmp/d20170103-15620-1s635ce/solution.rb:28:in `totally_recall'
     # /tmp/d20170103-15620-1s635ce/spec.rb:451:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

Finished in 0.02998 seconds
29 examples, 28 failures

Failed examples:

rspec /tmp/d20170103-15620-1s635ce/spec.rb:15 # ArnoldCPM has true and false constants
rspec /tmp/d20170103-15620-1s635ce/spec.rb:28 # ArnoldCPM can assign variables
rspec /tmp/d20170103-15620-1s635ce/spec.rb:466 # ArnoldCPM can define and call functions with arguments
rspec /tmp/d20170103-15620-1s635ce/spec.rb:489 # ArnoldCPM can define and call functions with return value
rspec /tmp/d20170103-15620-1s635ce/spec.rb:517 # ArnoldCPM returns 0 by default
rspec /tmp/d20170103-15620-1s635ce/spec.rb:540 # ArnoldCPM can take functions as arguments
rspec /tmp/d20170103-15620-1s635ce/spec.rb:583 # ArnoldCPM can return functions
rspec /tmp/d20170103-15620-1s635ce/spec.rb:613 # ArnoldCPM defines new inner functions for each function invocation
rspec /tmp/d20170103-15620-1s635ce/spec.rb:651 # ArnoldCPM supports basic recursion
rspec /tmp/d20170103-15620-1s635ce/spec.rb:695 # ArnoldCPM can calculate fibonacci(20) recursively
rspec /tmp/d20170103-15620-1s635ce/spec.rb:760 # ArnoldCPM can use closures in very convoluted ways
rspec /tmp/d20170103-15620-1s635ce/spec.rb:45 # ArnoldCPM has algebra that can sum numbers
rspec /tmp/d20170103-15620-1s635ce/spec.rb:62 # ArnoldCPM has algebra that can subtract numbers
rspec /tmp/d20170103-15620-1s635ce/spec.rb:79 # ArnoldCPM has algebra that can multiply numbers
rspec /tmp/d20170103-15620-1s635ce/spec.rb:96 # ArnoldCPM has algebra that can divide numbers
rspec /tmp/d20170103-15620-1s635ce/spec.rb:113 # ArnoldCPM has algebra that can calculate modulo
rspec /tmp/d20170103-15620-1s635ce/spec.rb:130 # ArnoldCPM has algebra that can chain multiple operations
rspec /tmp/d20170103-15620-1s635ce/spec.rb:154 # ArnoldCPM has algebra that can use variables in calculations
rspec /tmp/d20170103-15620-1s635ce/spec.rb:183 # ArnoldCPM has boolean arithmetic that given *or* returns truthy values if one of the operands is truthy
rspec /tmp/d20170103-15620-1s635ce/spec.rb:218 # ArnoldCPM has boolean arithmetic that given *or* returns falsy values if both operands are falsy
rspec /tmp/d20170103-15620-1s635ce/spec.rb:235 # ArnoldCPM has boolean arithmetic that given *or* between two truthy values returns the first one
rspec /tmp/d20170103-15620-1s635ce/spec.rb:252 # ArnoldCPM has boolean arithmetic that given *and* returns falsy values if either operand is falsy
rspec /tmp/d20170103-15620-1s635ce/spec.rb:287 # ArnoldCPM has boolean arithmetic that given *and* between two truthy values returns the second one
rspec /tmp/d20170103-15620-1s635ce/spec.rb:304 # ArnoldCPM has boolean arithmetic that has the same precedence of *or* and *and* operations
rspec /tmp/d20170103-15620-1s635ce/spec.rb:324 # ArnoldCPM has branching mechanism that can execute if statements
rspec /tmp/d20170103-15620-1s635ce/spec.rb:347 # ArnoldCPM has branching mechanism that can execute if-else statements
rspec /tmp/d20170103-15620-1s635ce/spec.rb:378 # ArnoldCPM has branching mechanism that can nest if-else statements
rspec /tmp/d20170103-15620-1s635ce/spec.rb:441 # ArnoldCPM has branching mechanism that considers functions truthy

История (2 версии и 1 коментар)

Здравко обнови решението на 28.12.2016 17:08 (преди над 7 години)

+module ArnoldCPM
+ attr_accessor :its_showtime, :i_let_him_go, :get_up, :get_down, :youre_fired
+ attr_accessor :he_had_to_split, :you_have_been_terminated, :talk_to_the_hand
+ attr_accessor :get_to_the_chopper, :here_is_my_invitation, :enough_talk
+ attr_accessor :i_lied, :no_problemo, :you_are_not_you_you_are_me
+ attr_accessor :get_your_ass_to_mars, :you_have_no_respect_for_logic
+ attr_accessor :let_off_some_steam_bennet, :consider_that_a_divorce
+ attr_accessor :i_need_your_clothes_your_boots_and_your_motorcycle
+ attr_accessor :because_im_going_to_say_please, :bull_shit, :do_it_no
+ attr_accessor :listen_to_me_very_carefully, :knock_knock
+ attr_accessor :ill_be_back, :hasta_la_vista_baby, :give_these_people_air
+
+ class Parser
+ end
+
+ def self.totally_recall(&block)
+ block.call
+ end
+
+ def self.printer=(*)
+
+ end
+end
+

Здравко обнови решението на 28.12.2016 17:58 (преди над 7 години)

-module ArnoldCPM
+class BasicObject
attr_accessor :its_showtime, :i_let_him_go, :get_up, :get_down, :youre_fired
attr_accessor :he_had_to_split, :you_have_been_terminated, :talk_to_the_hand
attr_accessor :get_to_the_chopper, :here_is_my_invitation, :enough_talk
attr_accessor :i_lied, :no_problemo, :you_are_not_you_you_are_me
attr_accessor :get_your_ass_to_mars, :you_have_no_respect_for_logic
attr_accessor :let_off_some_steam_bennet, :consider_that_a_divorce
attr_accessor :i_need_your_clothes_your_boots_and_your_motorcycle
attr_accessor :because_im_going_to_say_please, :bull_shit, :do_it_no
attr_accessor :listen_to_me_very_carefully, :knock_knock
attr_accessor :ill_be_back, :hasta_la_vista_baby, :give_these_people_air
- class Parser
+ def its_showtime
+ # TODO
end
+ def talk_to_the_hand(value)
+ puts value
+ end
+
+ def you_have_been_terminated
+ # TODO
+ end
+end
+
+module ArnoldCPM
def self.totally_recall(&block)
block.call
end
def self.printer=(*)
-
+ # TODO
end
end
+ArnoldCPM.printer = Kernel
+
+ArnoldCPM.totally_recall do
+ its_showtime
+ talk_to_the_hand 110_110
+ talk_to_the_hand 11_101_101
+ you_have_been_terminated
+end

Идеята на BasicObject е да бъде възможно най-минималистичният възможен клас. В момента си го затрупал с един куп ненужни (в общия случай) методи. Не трябваше да предаваш и експериментите накрая.


Надявам се задачата да ти е била забавна и полезна. Може да погледнеш нашето решение ако ти е интересно как сме подходили към проблема.