6 kyu
Bouncing Balls
10,487 of 93,560g964
Description:
A child is playing with a ball on the nth floor of a tall building. The height of this floor above ground level, h, is known.
He drops the ball out of the window. The ball bounces (for example), to two-thirds of its height (a bounce of 0.66).
His mother looks out of a window 1.5 meters from the ground.
How many times will the mother see the ball pass in front of her window (including when it's falling and bouncing)?
Three conditions must be met for a valid experiment:
- Float parameter "h" in meters must be greater than 0
- Float parameter "bounce" must be greater than 0 and less than 1
- Float parameter "window" must be less than h.
If all three conditions above are fulfilled, return a positive integer, otherwise return -1.
Note:
The ball can only be seen if the height of the rebounding ball is strictly greater than the window parameter.
Examples:
- 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).
Puzzles
Algorithms
Mathematics
Similar Kata:
Stats:
Created | May 2, 2015 |
Published | May 2, 2015 |
Warriors Trained | 207302 |
Total Skips | 44585 |
Total Code Submissions | 435606 |
Total Times Completed | 93560 |
Ruby Completions | 2199 |
Python Completions | 30941 |
Clojure Completions | 386 |
Java Completions | 10487 |
C# Completions | 5717 |
JavaScript Completions | 22614 |
Haskell Completions | 700 |
CoffeeScript Completions | 28 |
TypeScript Completions | 2336 |
C++ Completions | 6404 |
Elixir Completions | 314 |
PHP Completions | 2354 |
Crystal Completions | 37 |
F# Completions | 126 |
C Completions | 3524 |
Rust Completions | 1594 |
Swift Completions | 1077 |
Go Completions | 2316 |
R Completions | 281 |
Shell Completions | 133 |
OCaml Completions | 76 |
Kotlin Completions | 1270 |
Fortran Completions | 37 |
Julia Completions | 118 |
Scala Completions | 367 |
PowerShell Completions | 122 |
Nim Completions | 34 |
Racket Completions | 50 |
Reason Completions | 7 |
Prolog Completions | 30 |
Pascal Completions | 31 |
Factor Completions | 10 |
Raku Completions | 10 |
Perl Completions | 36 |
Elm Completions | 9 |
D Completions | 13 |
Erlang Completions | 18 |
Total Stars | 2601 |
% of votes with a positive feedback rating | 83% of 8182 |
Total "Very Satisfied" Votes | 5868 |
Total "Somewhat Satisfied" Votes | 1869 |
Total "Not Satisfied" Votes | 445 |