question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_floor_that_gives_way do 4 kind :numerical 5 describes "A wooden block of %{block_mass} rests on a soft horizontal floor. When an iron cylinder of " \ 6 "%{cylinder_mass} is placed on top of the block, the floor yields steadily and the block and the " \ 7 "cylinder together go down with an acceleration of %{acceleration}. Taking g as %{gravity}, " \ 8 "%{push}, in newtons?" 9 given block_mass: "2 kg" 10 given cylinder_mass: "25 kg" 11 given acceleration: "0.1 m/s2" 12 given gravity: "10 m/s2" 13 asks push: "how hard does the floor push up on them once it yields" 14 end
1 require_relative "../questions/a_floor_that_gives_way" 2 require_relative "../science/laws_of_motion/newtons_second_law" 3 4 solve :a_floor_that_gives_way , using: NewtonsSecondLaw do 5 objects :pair , :block , :cylinder , :floor 6 axes :y 7 pair . goes ( :sinking ) 8 deduce_from "Taking g as" , pair . weight . direction => - y 9 10 take block_mass: block . mass 11 take cylinder_mass: cylinder . mass 12 take acceleration: pair . acceleration . magnitude 13 take gravity: g 14 15 deduce_from "placed on top of the block" , pair . mass => block . mass + cylinder . mass 16 deduce_from "go down" , pair . acceleration . direction => - y 17 18 push = pair . force ( by: floor ). magnitude 19 answer push :, in: "N" , figures: 4 20 21 conclusion "The floor holds up less than the full weight, by just what it takes to let the two sink " \ 22 "together; by the third law they press down on the floor with the same force." 23 end
1 require_relative "../solutions/a_floor_that_gives_way" 2 3 play_with :a_floor_that_gives_way do 4 title "A Floor That Gives Way" 5 end