Ad
  • Custom User Avatar

    This is so elegant. I love it.

  • Default User Avatar

    the code should return -1 when any of the 3 conditions are not met. The if statement is the check to see if bounce is between 0 and 1 and the while loop checks to see if the window is above 0 and the height at which the ball being dropped is higher than the window. If any of these aren't true then it will skip the if statement and therefore the while loop and return -1.

  • Custom User Avatar

    Confession time. This was basically my solution, however my logic says seen should start at 1 (as it will bounce down once and not come up again or forfeight and return -1), my test results were all coming back 2 more than the answer, so I changed seen to -1 and tested it to see if it would work with ALL the tests aaand it did. But I don't understand why... if someone could share some insight with me I would appreciate it very much

  • Default User Avatar

    it doesnt work on:(2, 0.5, 1.5). it should be -1 but it returns 1.

  • Default User Avatar

    If you mean (1, 0.2, 1): the while cycle has "greater" not "greater or equal" sign, so the body of cycle is skipped and seen stays on -1

  • Default User Avatar

    Question: how does this solution factor in when the ball is equal to the hight of the window?
    that would make it +1.
    i can see that it does but I can't wrap my head around it here

  • Default User Avatar

    This solution is so beautiful!

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution