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
PostgreSQLv16

Her vises resultatet af din kode

Visible tests
1
Input
3, 0.66, 1.5
Expected3
2
Input
30, 0.66, 1.5
Expected15
3
Input
40, 0.4, 10
Expected3
4
Input
10, 0.6, 10
Expected-1
5
Input
-5, 0.66, 1.5
Expected-1
6
Input
5, 1, 1
Expected-1
Focus radio
Paused · SomaFM · Fluid