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.
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, notissue
. If there was such a gross mistake in the reference solution, users would have noticed it by now.You are wrongfully checking distance to neighbours. You need to check against the target locations, not accumulate neighbours closests positions.
[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.