Ball Past the Window
A ball is dropped from height h, and after each bounce it rises to bounce times its previous height. Write bouncing_ball to count how many times the ball is visible from a window at height window: once while falling, then again on each upward and downward pass. If the input is invalid — h <= 0, bounce is not between 0 and 1, or window >= h — return -1.
Примеры
Ввод
3, 0.66, 1.5Вывод
3Ввод
30, 0.66, 1.5Вывод
15Ввод
40, 0.4, 10Вывод
3Нужно реализовать
def bouncing_ball(h: float, bounce: float, window: float) -> int:
Теги
math
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
3, 0.66, 1.5Expected
32
Input
30, 0.66, 1.5Expected
153
Input
40, 0.4, 10Expected
34
Input
10, 0.6, 10Expected
-15
Input
-5, 0.66, 1.5Expected
-16
Input
5, 1, 1Expected
-1Focus radio
Paused · SomaFM · Fluid