| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
- manifest.json
- JDBC
- TABLESPACE
- react
- java api
- IBM
- isSquare
- Debug
- react hook
- custom hook
- useEffect
- TypeScript
- codewar
- codewars
- type
- descendingOrder
- DB2
- Today
- Total
taesik
how many times father see kid's falling and bouncing ball 본문
how many times father see kid's falling and bouncing ball
taesikk 2022. 1. 25. 14:31A child is playing with a ball on the nth floor of a tall building. The height of this floor, 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 father looks out of a window 1.5 meters from the ground.
How many times will the father see the ball pass in front of her window (including when it's falling and bouncing?
my solution
function bouncingBall(h, bounce, window) {
// your code here
if(bounce ===0||bounce < 0||bounce >1||bounce ===1 || window> h || window ===h || h===0 || h <0) return -1;
count = 1;
while(h>window) {
h=h*bounce;
if(h>window) count+=2;
}
return count;
}
const bouncingBall=(h, b, w)=>(b>=1 || h<w || b<=0) ? -1 : Math.ceil(Math.log(w/h)/Math.log(b))*2-1;
https://people.richland.edu/james/lecture/m116/logs/properties.html
4.3 - Properties of Logarithms
4.3 - Properties of Logarithms Change of Base Formula One dilemma is that your calculator only has logarithms for two bases on it. Base 10 (log) and base e (ln). What is to happen if you want to know the logarithm for some other base? Are you out of luck?
people.richland.edu
'functions and trick > typescript_javascript' 카테고리의 다른 글
| makes this string uppercasegives it sorted in alphabetical order by last name. (0) | 2022.01.25 |
|---|---|
| Sum of numbers from 0 to N (0) | 2022.01.25 |
| Write Number in Expanded Form (0) | 2022.01.25 |
| alpabet war (0) | 2022.01.25 |
| isAscending (0) | 2022.01.25 |