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.
I used that same algorithm, just need to tweak for the general case.
There are both recursive solutions and iterative solutions. Maybe recursion is simpler (but keep an eye on performance).
This comment is hidden because it contains spoiler information about the solution
Your code changes the content of the arrays
x
,y
,px
, andpy
. Arrays in Javascript are passed by reference, so this can cause problems if the code that called your function needed that data for other purposes.I've just tweaked the test setup so that it doesn't use those arrays for anything after calling your function; your solution should pass now.
In general, though, if you are passed an array, it's safest to avoid changing its content unless you know for sure that it's not being used anywhere else.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I have it down to 2 failing now, so close.
This comment is hidden because it contains spoiler information about the solution
Hey @ccombe I also hit the recursion limit and was able to get around it by combining the repetitive operations. I recommend printing the inputs and looking in the logs for a pattern :)
If it's worth anything, I can tell you i don't think this kata is 7 kyu. I think that even if solution looks simple, it's not THAT easy to get to it. Don't get discouraged, and keep trying :)
OK looks like I can get past the repeating line error and now I can solve 116 with 91 failing and it seems to be there I have largeish numbers that don't quite get clos enough to eachother. Time for bed - ill keep trying tomorrow.
Thanks that is helpful but it's almost midnight here and I'm running out of ideas.
I think I need a way of being able to check if the line will repeat again (many times) because the value or either a or b is so large that it needs to be reduced significantly.
I woudl think checking to see if the difference between the a and b is > 3 * a or 3 * b, then set a = 2 * b or b = 2 * a but that doesn't feel right.
Note how in previous post you have this:
[previous line repeated 996 more times]
. Maybe you could find a way to avoid so many identical lines? It should not be difficult. But yeah, I wonder if still in scope of a white kata...I'm losing my mind on Python.
I keep hitting the recursion limit which seems like a Python gap compared to other languages but then I assume I'm doing something stupid with my logic - however I see a lot of others having the same issue with the same test.
solve(100000000000,3)
Any suggestions for how to best approach solving this or if there's a specific feature / approach to trye would be appreciated.
Should I be looking into generators and yields as an alternative?
Amy suggestions / tips are appreciated.
Loading more items...