question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :hot_water_cooling_from_sixty do 4 kind :numerical 5 describes "Hot water cools from %{first_from} to %{first_to} in the first %{first_time} and to %{then_to} in the " \ 6 "next %{then_time}. Then %{surroundings}, in °C?" 7 given first_from: "60 °C" 8 given first_to: "50 °C" 9 given first_time: "10 min" 10 given then_to: "42 °C" 11 given then_time: "10 min" 12 asks surroundings: "the temperature of the surroundings is" 13 end
1 require_relative "../questions/hot_water_cooling_from_sixty" 2 require_relative "../science/thermal_properties_of_matter/newtons_law_of_cooling" 3 4 solve :hot_water_cooling_from_sixty , using: NewtonsLawOfCooling do 5 objects :water , :air 6 water . goes ( :cooling_first , in: air ) 7 water . goes ( :cooling_next , in: air ) 8 9 take first_from: water . temperature ( at: cooling_first . start ) 10 take first_to: water . temperature ( at: cooling_first . end ) 11 take first_time: cooling_first . time_taken 12 take then_to: water . temperature ( at: cooling_next . end ) 13 take then_time: cooling_next . time_taken 14 deduce_from "in the next" , water . temperature ( at: cooling_next . start ) => water . temperature ( at: cooling_first . end ) 15 16 surroundings = air . temperature 17 answer surroundings :, in: "°C" 18 19 conclusion "The water cools faster the hotter it is than its surroundings; the second drop of 8 degrees against " \ 20 "the first of 10 puts the surroundings near 10 °C." 21 end
1 require_relative "../solutions/hot_water_cooling_from_sixty" 2 3 play_with :hot_water_cooling_from_sixty do 4 title "Hot Water Cooling From Sixty" 5 end