question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :forty_minutes_out_velocity do 4 kind :numerical 5 describes "A man walks on a straight road from his home to a market %{distance} away with a speed of " \ 6 "%{speed_there}. Finding the market closed, he instantly turns and walks back home with a speed of " \ 7 "%{speed_back}. %{average_velocity} over the interval of time 0 to %{interval}, in km/h?" 8 given distance: "2.5 km" , speed_there: "5 km/h" , speed_back: "7.5 km/h" , interval: "40 min" 9 asks average_velocity: "What is the magnitude of average velocity of the man" 10 end
1 require_relative "../questions/forty_minutes_out_velocity" 2 require_relative "../science/motion_in_a_straight_line/velocity" 3 4 solve :forty_minutes_out_velocity , using: Velocity do 5 objects :man 6 instants :start , :market , :later 7 man . goes ( :to_market , during: start .. market ) 8 man . goes ( :turning_back , during: market .. later ) 9 man . goes ( :walking , during: start .. later ) 10 take distance: man . position ( at: market ), speed_there: to_market . average_speed , 11 speed_back: turning_back . average_speed , interval: walking . time_taken 12 deduce_from "from his home" , man . position ( at: start ) => "0 km" 13 deduce_from "on a straight road" , to_market . average_velocity => to_market . average_speed 14 deduce_from "walks back home" , turning_back . average_velocity => - turning_back . average_speed 15 average_velocity = walking . average_velocity 16 answer average_velocity :, in: "km/h" , figures: 4 17 conclusion "By the end of the interval he has walked part of the way back, so the average velocity counts " \ 18 "only how far from home he is now, over the whole time." 19 end
1 require_relative "../solutions/forty_minutes_out_velocity" 2 3 play_with :forty_minutes_out_velocity do 4 title "Forty Minutes Out: Velocity" 5 end