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.
This was by far the most interesting kata I have done on this site.
Thanks
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Lovely kata! Thanks for it! :)
That can happen if your algorithm isn't efficient. Any method that relies on finding the depth of each pixel separately will likely be too slow on the large images.
running big test, my program always runs out of time...
An ill-conditioned problem is one where small changes to the inputs can cause a large change in the answer. In this kata, the most ill-conditioned test cases are ones where all the given points lie on a relatively small part of the sphere. (Imagine trying to determine where the centre of the Earth is, given only the 3D coordinates of some points on one small Pacific island.) In computational terms, this means that small floating-point errors can cause a relatively large error in the final answer -- so you need to come up with an algorithm that minimizes the effects of such errors.
The "proper test" you propose is much less stringent than the one the kata actually uses. In an ill-conditioned test case, there will be many points P with the property that the distances from P to the given points are all approximately the same. But most of them are relatively far away from the real centre of the sphere; some are even outside the sphere. That "real centre" is the point that was used as the centre when constructing the test case; that's the point you need to get close to.
Don't give up; it can be done. :)
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Here's the relevant region of the test image, consisting of pixels of colour 5.
5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,
5,5,5,E,E,A,5,5,5,
5,5,5,E,A,A,5,5,5,
5,5,5,5,5,5,
5,5,5,5,5,5,
5,5,5,5,5,5,
The Es represent the expected answer: pixels 212, 213, and 241. The As are the additional pixels present in your actual solution : 214, 242, and 243.
All the E pixels have depth 4, which is the maximum depth for any pixel in this region. But one of the A pixels (pixel 243) has depth 2: you can get out of the region of 5s by taking just one step to the right and one step down. The other two A pixels have depth 3.
This comment is hidden because it contains spoiler information about the solution
Your alternative solution timed out when I tried it. It's not really what I'd call a one-pass solution, as there's a lot of recursive hard work involved in each iteration of the single pass. Effectively, it finds the depth of each pixel separately, without using any of the previously-found depths of other pixels.
This comment is hidden because it contains spoiler information about the solution
Ty for this kata! Did it without any googling, took a while, it feels so cool to find your own way to do things without someones help, im so excited
Try to narrow it down to a specific test case. Find out what your code is returning in that case. That'll probably tell you what the problem is.
The only asserts in the JS version of this kata are standard ones (
Test.expect()
).Loading more items...