Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bouncingBall(h, bounce, window):
- BounceFactor = bounce
- BallDropHeight = h
- ViewerHeight = window
- BounceLeft = h
- BallSeenTimes = 1
- if bounce > 1 or bounce < 0 or window >= h or h ==0:
- return -1
- else:
- while (BounceLeft > ViewerHeight):
- BounceLeft = BounceLeft * BounceFactor
- if (BounceLeft > ViewerHeight):
- BallSeenTimes = BallSeenTimes + 2
- else:
- break
- return BallSeenTimes
Add Comment
Please, Sign In to add comment