question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_bullet_from_a_moving_van do 4 kind :numerical 5 describes "A police van doing %{van_speed} fires a bullet at %{muzzle_speed}, relative to the van, " \ 6 "at a car ahead doing %{car_speed} the same way. %{speed}, in m/s?" 7 given van_speed: "30 km/h" , car_speed: "192 km/h" , muzzle_speed: "150 m/s" 8 asks speed: "At what speed does the bullet hit the car" 9 end
1 require_relative "../questions/a_bullet_from_a_moving_van" 2 require_relative "../science/motion_in_a_straight_line/relative_velocity" 3 4 solve :a_bullet_from_a_moving_van , using: RelativeVelocity do 5 objects :bullet , :van , :car 6 take van_speed: van . velocity , car_speed: car . velocity , muzzle_speed: bullet . velocity ( from: van ) 7 speed = bullet . velocity ( from: car ) 8 answer speed :, in: "m/s" 9 conclusion "What does the damage is the bullet's speed as the car sees it: the van's speed adds " \ 10 "to the bullet's, and the car's running away takes from it." 11 end
1 require_relative "../solutions/a_bullet_from_a_moving_van" 2 3 play_with :a_bullet_from_a_moving_van do 4 title "A Bullet from a Moving Van" 5 end