question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_body_cools_in_a_room do 4 kind :numerical 5 describes "A body cools from %{first_from} to %{first_to} in %{first_time}. The temperature of the surroundings " \ 6 "is %{room}. %{time} to cool from %{then_from} to %{then_to}, in minutes?" 7 given first_from: "80 °C" 8 given first_to: "50 °C" 9 given first_time: "5 min" 10 given room: "20 °C" 11 given then_from: "60 °C" 12 given then_to: "30 °C" 13 asks time: "How long does it take" 14 end
1 require_relative "../questions/a_body_cools_in_a_room" 2 require_relative "../science/thermal_properties_of_matter/newtons_law_of_cooling" 3 4 solve :a_body_cools_in_a_room , using: NewtonsLawOfCooling do 5 objects :body , :room 6 body . goes ( :cooling_first , in: room ) 7 body . goes ( :cooling_later , in: room ) 8 9 take first_from: body . temperature ( at: cooling_first . start ) 10 take first_to: body . temperature ( at: cooling_first . end ) 11 take first_time: cooling_first . time_taken 12 take room: room . temperature 13 take then_from: body . temperature ( at: cooling_later . start ) 14 take then_to: body . temperature ( at: cooling_later . end ) 15 16 time = cooling_later . time_taken 17 answer time :, in: "min" , figures: 1 18 19 conclusion "The body loses heat at a rate set by how much hotter than its surroundings it is; the same " \ 20 "drop nearer room temperature comes more slowly and takes longer." 21 end
1 require_relative "../solutions/a_body_cools_in_a_room" 2 3 play_with :a_body_cools_in_a_room do 4 title "A Body Cools in a Room" 5 end