We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In a 2 dimensional coordinate system you draw your axis in one direction each... so X is either Latitude or Longitude and Y is the other.
In such a coordinate system the euclidean distance is equivalent to pythagorean theorem, ie the square of the hypotenuse is equal to the sum of the squares of the other two sides.
To draw the side in x => Longitude (graphs usually have X going from left to right) you would have
X^2 = (Max(Long)-Min(Long))^2
Y^2 = (Max(Lat)-Min(Lat))^2
ie as both @camcrews and @givonz say (though typo from @givonz) the formula for the euclidean distance from the problem given should be
sqrt((b-a)^2+(d-c)^2)
.
Using the erroneous formula below:
sqrt((c-a)^2+(d-b)^2)
I did get the answer flagged as correct from my query. But if you expect people to get this you should either state this formula in the question or, if you want them to read it in wikipedia, then correct the problem statement.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 19
You are viewing a single comment's thread. Return to all comments →
In a 2 dimensional coordinate system you draw your axis in one direction each... so X is either Latitude or Longitude and Y is the other.
In such a coordinate system the euclidean distance is equivalent to pythagorean theorem, ie the square of the hypotenuse is equal to the sum of the squares of the other two sides.
To draw the side in x => Longitude (graphs usually have X going from left to right) you would have
X^2 = (Max(Long)-Min(Long))^2
Y^2 = (Max(Lat)-Min(Lat))^2
ie as both @camcrews and @givonz say (though typo from @givonz) the formula for the euclidean distance from the problem given should be
sqrt((b-a)^2+(d-c)^2)
.
Using the erroneous formula below:
sqrt((c-a)^2+(d-b)^2)
I did get the answer flagged as correct from my query. But if you expect people to get this you should either state this formula in the question or, if you want them to read it in wikipedia, then correct the problem statement.