question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :both_times_a_ball_passes_a_ledge do 4 kind :numerical 5 describes "A ball is thrown straight up at %{throw_speed} from the foot of a wall with a ledge %{height} up it. " \ 6 "Taking g as %{gravity}, %{times}, in seconds?" 7 given throw_speed: "20 m/s" 8 given height: "15 m" 9 given gravity: "9.8 m/s2" 10 asks times: "at what times after the throw does it pass the ledge" 11 end
1 require_relative "../questions/both_times_a_ball_passes_a_ledge" 2 require_relative "../science/motion_in_a_straight_line/uniform_acceleration" 3 4 solve :both_times_a_ball_passes_a_ledge , using: UniformAcceleration do 5 objects :ball 6 ball . goes ( :flying ) 7 8 deduce_from "thrown straight up" , "Taking g as" , ball . acceleration => - g 9 take throw_speed: ball . initial_velocity , gravity: g , height: ball . final_position 10 deduce_from "from the foot of a wall" , ball . initial_position => "0 m" 11 take times: flying . time_taken 12 answer find_value ( :times , in: "s" , figures: 3 , root: :all ) 13 14 conclusion "The ball passes the ledge twice, once rising and once falling back, so both times answer the " \ 15 "question; they sit evenly either side of the top of the flight, about 2.04 s after the throw." 16 end
1 require_relative "../solutions/both_times_a_ball_passes_a_ledge" 2 3 play_with :both_times_a_ball_passes_a_ledge do 4 title "Both Times a Ball Passes a Ledge" 5 end