Ad
  • Default User Avatar

    Your calcPathDistance() function is incorrect: it does not correctly calculate the Euclidian distance between two points for some coordinates. If you want to convince yourself of it, try an online tool like GeoGebra, place two points on [0, 4] and [5, 1] and measure the distance; it is ~ 5.830, not ~ 6.2.


    Please note that you should use the question tag to ask for help, not issue. If there was such a gross mistake in the reference solution, users would have noticed it by now.

  • Custom User Avatar

    You are wrongfully checking distance to neighbours. You need to check against the target locations, not accumulate neighbours closests positions.

  • Custom User Avatar

    [3, 2] has the same distance to [2, 0] as to [1, 3], [1, 3] has the lowest row index, so choose that one to point to.