question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :there_and_back_velocity do 4 kind :numerical 5 describes "A man walks %{path_there} to a market in %{time_there}, finds it shut, and walks straight home " \ 6 "in %{time_back}. %{average_velocity}, in km/h?" 7 given path_there: "2.5 km" , time_there: "30 min" , time_back: "20 min" 8 asks average_velocity: "What is the size of his average velocity over the whole walk" 9 end
1 require_relative "../questions/there_and_back_velocity" 2 require_relative "../science/motion_in_a_straight_line/velocity" 3 4 solve :there_and_back_velocity , 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 assume man . position ( at: start ) => "0 km" 12 deduce_from "walks straight home" , man . position ( at: home ) => "0 km" 13 average_velocity = walking . average_velocity 14 answer average_velocity :, in: "km/h" 15 conclusion "Average velocity asks only where he ended up. He ended where he began, so however " \ 16 "far he walked it is nothing." 17 end
1 require_relative "../solutions/there_and_back_velocity" 2 3 play_with :there_and_back_velocity do 4 title "There and Back: Velocity" 5 end