question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_bat_s_call_into_water do 4 kind :numerical 5 describes "A bat emits ultrasonic sound of frequency %{frequency} in air. Speed of sound in water is %{speed}. If " \ 6 "the sound meets a water surface, %{wavelength}, in metres?" 7 given frequency: "1000 kHz" 8 given speed: "1486 m/s" 9 asks wavelength: "what is the wavelength of the transmitted sound" 10 end
1 require_relative "../questions/a_bat_s_call_into_water" 2 require_relative "../science/waves/travelling_wave" 3 4 solve :a_bat_s_call_into_water , using: TravellingWave do 5 objects :call , :transmitted 6 7 take frequency: call . frequency 8 take speed: transmitted . wave_speed 9 10 deduce_from "meets a water surface" , transmitted . frequency => call . frequency 11 12 wavelength = transmitted . wavelength 13 answer wavelength :, in: "m" , figures: 3 14 15 conclusion "Crossing into water the sound keeps the frequency it was made with but runs faster, so each wave " \ 16 "stretches longer in the same proportion." 17 end
1 require_relative "../solutions/a_bat_s_call_into_water" 2 3 play_with :a_bat_s_call_into_water do 4 title "A Bat's Call into Water" 5 end