question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :there_and_back_speed do 4 kind :numerical 5 describes "A man walks %{path_there} to a market in %{time_there}, finds it shut, and walks straight home in " \ 6 "%{time_back}. %{average_speed}, in km/h?" 7 given path_there: "2.5 km" , time_there: "30 min" , time_back: "20 min" 8 asks average_speed: "What is his average speed over the whole walk" 9 end
1 require_relative "../questions/there_and_back_speed" 2 require_relative "../science/motion_in_a_straight_line/velocity" 3 4 solve :there_and_back_speed , using: Velocity do 5 objects :man 6 instants :start , :market , :home 7 man . goes ( :to_market , during: start .. market ) 8 man . goes ( :back_home , during: market .. home ) 9 man . goes ( :walking , during: start .. home ) 10 take path_there: to_market . path_length , time_there: to_market . time_taken , time_back: back_home . time_taken 11 deduce_from "walks straight home" , back_home . path_length => "2.5 km" 12 average_speed = walking . average_speed 13 answer average_speed :, in: "km/h" 14 conclusion "Average speed counts every step of the path, so it is never less than the size of " \ 15 "the average velocity, and a tired man is not told he stood still." 16 end
1 require_relative "../solutions/there_and_back_speed" 2 3 play_with :there_and_back_speed do 4 title "There and Back: Speed" 5 end