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.
bruh
Thank you, I thought that distance should be calculated as cell-by-cell path, and sorry for wrong mark:)
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.Hey, it's me again:) Sorry for disturbing, but i have one more suspision about reference algorithm correctness. Here is the deal:
requestedDirectionsTo: 'S'
Village map:
Reference solution:
My solution:
Distances map:
Difference between solutions in
[0,4]
and[1,4]
. Let's take[0,4]
for example, in ref solution it points to keyPlace[5,1]
with distance 6.2, in my solution it points to keyPlace[6,4]
with distance 6.0, why so? Thank you for your help:)Oh, now I'm understanding this, thank you)
[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.It seems that current solve implementation is not assigned with task conditions.
"In case of a tie, prefer the location with lowest row index.
If there still is a tie, prefer the location with lowest column index."
Here is an example that generated as random test for me:
Village map:
requestedDirectionsTo: #
Reference solution:
My solution:
Distances map:
Look at the cell [3, 2], it has 2 cells around with distances 1.0 ([2, 1] and [2, 3]), but reference solution prefer cell with higher column index.
Hello. The function returns a single location, but a bug report reports that 2 positions have been received. console.log() shows return value. Is it possible that task verification has a problem?
http://joxi.ru/12M8zyBH00qMdm