question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_steel_tape_on_a_hot_day do 4 kind :numerical 5 describes "A steel tape 1m long is correctly calibrated for a temperature of %{calibrated}. The length of a steel " \ 6 "rod measured by this tape is found to be %{reading} on a hot day when the temperature is %{hot}. " \ 7 "Coefficient of linear expansion of steel = %{expansion}. %{actual}, in cm?" 8 given calibrated: "27.0 °C" 9 given reading: "63.0 cm" 10 given hot: "45.0 °C" 11 given expansion: "1.20e-5 K-1" 12 asks actual: "What is the actual length of the steel rod on that day" 13 end
1 require_relative "../questions/a_steel_tape_on_a_hot_day" 2 require_relative "../science/thermal_properties_of_matter/thermal_expansion" 3 4 solve :a_steel_tape_on_a_hot_day , using: ThermalExpansion do 5 objects :tape , :rod 6 7 take calibrated: tape . temperature_at_first 8 take reading: tape . length_at_first 9 take hot: tape . temperature_after 10 take expansion: tape . coefficient_of_linear_expansion 11 12 deduce_from "measured by this tape" , rod . length_after => tape . length_after 13 14 actual = rod . length_after 15 answer actual :, in: "cm" , figures: 6 16 17 conclusion "On the hot day the tape has grown, so each of its marked centimetres is a little longer " \ 18 "than a true one; the rod is as long as that stretched piece of tape." 19 end
1 require_relative "../solutions/a_steel_tape_on_a_hot_day" 2 3 play_with :a_steel_tape_on_a_hot_day do 4 title "A Steel Tape on a Hot Day" 5 end