question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_pendulum_taken_to_the_moon do 4 kind :numerical 5 describes "The acceleration due to gravity on the surface of moon is %{moon_g}. %{moon_period} of a simple " \ 6 "pendulum on the surface of moon if its time period on the surface of earth is %{earth_period}, where g " \ 7 "is %{earth_g}, in seconds?" 8 given moon_g: "1.7 m/s2" 9 given earth_period: "3.5 s" 10 given earth_g: "9.8 m/s2" 11 asks moon_period: "What is the time period" 12 end
1 require_relative "../questions/a_pendulum_taken_to_the_moon" 2 require_relative "../science/oscillations/simple_pendulum" 3 4 solve :a_pendulum_taken_to_the_moon , using: SimplePendulum do 5 objects :earth , :moon 6 object :pendulum , on: earth 7 object :lunar_pendulum , on: moon 8 9 take moon_g: moon . surface_gravity 10 take earth_g: earth . surface_gravity 11 take earth_period: pendulum . period 12 13 deduce_from "a simple pendulum" , lunar_pendulum . length_of_the_string => pendulum . length_of_the_string 14 15 moon_period = lunar_pendulum . period 16 answer moon_period :, in: "s" , figures: 2 17 18 conclusion "The same string swings in weaker gravity, so the bob is pulled back more gently and each swing " \ 19 "takes longer, by the square root of how much weaker gravity is." 20 end
1 require_relative "../solutions/a_pendulum_taken_to_the_moon" 2 3 play_with :a_pendulum_taken_to_the_moon do 4 title "A Pendulum Taken to the Moon" 5 end