you dont even need loops, arithmetic progression sum is (a1+an)*n/2. I guess that exercise is about learning synthax. Otherwise i would be able to do it in straightforward formula in excel without loops.
Nice, even if it appears having issues with cases in which one of the bounces isn't strictly > of window, like this:
assertEquals(1, BouncingBall.bouncingBall(2.0, 0.5, 1.0));
Recursion's solution is almost always worse than for-loop statement in efficiency. And every recursion can be replaced by for-loop, but sometimes it's really hard.
Fixed in this fork
nice
you dont even need loops, arithmetic progression sum is (a1+an)*n/2. I guess that exercise is about learning synthax. Otherwise i would be able to do it in straightforward formula in excel without loops.
Much more elegant than my solution.
Nice, even if it appears having issues with cases in which one of the bounces isn't strictly > of window, like this:
assertEquals(1, BouncingBall.bouncingBall(2.0, 0.5, 1.0));
This comment is hidden because it contains spoiler information about the solution
so easy with your solution !
wth!!!!
This solution fails for 3 reasons:
Here is a version that works with my tests :
Code is as follows: https://www.codewars.com/kata/reviews/55472965761db2bab8000085/groups/623b5f73dff0240001526f40.
Tell me what you think.
Apparently in java8, ArrayList.addAll(null) returns stackoverflow !!
At some point one of the sqInRect will return null so the whole will fail
There is a ton of comments blaming recursion below. But let's stop for a second and look at the code ones again.
Two main drawbacks impact performance here:
This comment is hidden because it contains spoiler information about the solution
this is clearly the better contender for best practices imo
Recursion's solution is almost always worse than for-loop statement in efficiency. And every recursion can be replaced by for-loop, but sometimes it's really hard.
Loading more items...