Ad
  • Custom User Avatar

    This was by far the most interesting kata I have done on this site.

    Thanks

  • 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

  • Custom User Avatar

    Lovely kata! Thanks for it! :)

  • Default User Avatar

    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.

  • Default User Avatar

    running big test, my program always runs out of time...

  • Default User Avatar

    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. :)

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Default User Avatar

    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.

  • Custom User Avatar

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

  • Default User Avatar

    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.

  • Default User Avatar

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

  • Custom User Avatar

    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

  • Default User Avatar

    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...