Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
No problem, about using an external var, watch out because it'll keep its value when your function is called more than once, and that'll give you wrong results.
A little push in the right direction is the way to do it. At least for me.
@Chrono79 Thanks again for the help and the great resource you linked. Recursion was happening however since I did not return the recursive function the value was being lost as the recursive stack frames unwind. This was solved by simply returning the recursive function or could have also been solved by using variables declared outside of the function that's state is changed by each recursive call.
Thanks again for not giving me the answer but pointing me in the right direction.
Try seeing how recursion works with some examples and you'll see what you're doing wrong there.
Because you're doing recursion wrong. See what your code does here: http://www.pythontutor.com/visualize.html#mode=edit
This comment is hidden because it contains spoiler information about the solution
No problem, you can see what the input value is printing it: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#print-input
No, that's an example value, h is a parameter of your function, it's not a fixed value.
Yes.
Yes.
So how I understood it is. The h is anything greater than zero, window, where the mother is, value is changing and is greater than zero but less than h, and the ball is dropped from h.
@Chrono79, Thanks you were right. It was because I wasn’t validating all the inputs. I do not know what test case was causing the infinite loop but once I validated all the inputs it fixed the issue. My guess was there was a situation where window was less than 0 and my h value never goes below zero so it created an infinite loop.
When I press ATTEMPT I pass most of the tests but not all. I know there is a problem with my code and that it most likely
has to do with my interpretation of the instructions. So, I would be grateful if someone could clarify the following:
Instructions state: "His mother looks out of a window 1.5 meters from the ground."
I interpret this to mean that the height of the window where mother is is fixed (i.e, always 1.5). Is this right?
Now, the function bouncingBall has a window parameter (as well as a height parameter, h).
So, what is the relationship between h and window?
Is window actually the height where the mother is? (which means that that height is not always 1.5, and, so, NOT fixed)
I'm assuming the ball is dropped from h. Is this right?
Anyway, it would be awesome if anyone could shed some light on this.
Thanks.
Not exactly, it passes all the tests until it times out with another one. You also have an infinite loop because you didn't validate the input values as per instructions.
There is nothing wrong with the tests, read the instructions again, you're not validating the input and hence your code has an infinite loop.
This comment is hidden because it contains spoiler information about the solution