A child plays with a ball on the nth floor of a big building. The height of this floor is known.
(float parameter "h" in meters. Condition 1) : h > 0)
He lets out the ball. The ball bounces for example to two-thirds of its height.
(float parameter "bounce". Condition 2) : 0 < bounce < 1)
His mother looks out of a window that is 1.5 meters from the ground.
(float parameters "window". Condition 3) : window < h).
How many times will the mother see the ball either falling or bouncing in front of the window?
If all three conditions above are fulfilled, return a positive integer, otherwise return -1.
Note
You will admit that the ball can only be seen if the height of the rebouncing ball is stricty greater than the window parameter.
Example:
h = 3, bounce = 0.66, window = 1.5, result is 3
h = 3, bounce = 1, window = 1.5, result is -1 (Condition 2) not fulfilled).
'매일매일개발 > Codewars' 카테고리의 다른 글
codewars #46 Your order, please (6kyu) (1) | 2018.05.22 |
---|---|
codewars #45 Sort - one, three, two (5kyu) (0) | 2018.05.21 |
codewars #42 Delete occurrences of an element if it occurs more than n times (6kyu) (0) | 2018.05.16 |
codewars #41 Dashatize it (6kyu) (0) | 2018.05.15 |
codewars #40 What's a Perfect Power anyway? (5kyu) (1) | 2018.05.14 |