question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_ball_off_a_roof_rises do 4 kind :numerical 5 describes "A ball is thrown straight up at %{throw_speed} from the top of a building %{building_height} tall. Taking g as " \ 6 "%{gravity}, %{height}, in metres?" 7 given throw_speed: "20 m/s" 8 given building_height: "25 m" 9 given gravity: "10 m/s2" 10 asks height: "how high above the ground does it rise" 11 end
1 require_relative "../questions/a_ball_off_a_roof_rises" 2 require_relative "../science/motion_in_a_straight_line/uniform_acceleration" 3 4 solve :a_ball_off_a_roof_rises , using: UniformAcceleration do 5 objects :ball 6 ball . goes ( :rising ) 7 8 deduce_from "thrown straight up" , "Taking g as" , ball . acceleration => - g 9 take throw_speed: ball . initial_velocity , building_height: ball . initial_position , gravity: g 10 deduce_from "how high above the ground does it rise" , ball . final_velocity => "0 m/s" 11 take height: ball . final_position 12 answer find_value ( :height , in: "m" ) 13 14 conclusion "At the top the ball is still for an instant, so the speed it had is all spent " \ 15 "against gravity over the height it climbs." 16 end
1 require_relative "../solutions/a_ball_off_a_roof_rises" 2 3 play_with :a_ball_off_a_roof_rises do 4 title "A Ball off a Roof Rises" 5 end