question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_ball_off_a_roof_lands 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}, %{time}?" 7 given throw_speed: "20 m/s" 8 given building_height: "25 m" 9 given gravity: "10 m/s2" 10 asks time: "how many seconds pass before it hits the ground" 11 end
1 require_relative "../questions/a_ball_off_a_roof_lands" 2 require_relative "../science/motion_in_a_straight_line/uniform_acceleration" 3 4 solve :a_ball_off_a_roof_lands , 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 , building_height: ball . initial_position , gravity: g 10 deduce_from "hits the ground" , ball . final_position => "0 m" 11 take time: flying . time_taken 12 answer find_value ( :time , in: "s" ) 13 14 conclusion "There is no need to split the flight at the top: the acceleration never changes, so " \ 15 "one equation covers the way up and the way down. It has two roots, and only the one " \ 16 "after the throw is an answer." 17 end
1 require_relative "../solutions/a_ball_off_a_roof_lands" 2 3 play_with :a_ball_off_a_roof_lands do 4 title "A Ball off a Roof Lands" 5 end