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.
Again, you're matching up latitude and longitude values from the table with your b-a and d-c distance calculations. That is not what the instructions tell you to do. You need to query four numbers from the table. Assemble the four numbers into two points — it does not matter whether or not a number originally corresponded to a geographic x or y coordinate. These numbers do not correspond to locations on a 2D plane as far as we're concerned until such a time as they are assembled into points P1 and P2. Once you've found the values that create points P1 and P2, they are points on a 2D plane that you must find the Euclidean distance for. Your sqrt((b-a)^2+(d-c)^2) formula is not the Euclidean distance between points P1(a, b) and P2(c, d), which is why your formula is not correct.
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 →
Again, you're matching up latitude and longitude values from the table with your b-a and d-c distance calculations. That is not what the instructions tell you to do. You need to query four numbers from the table. Assemble the four numbers into two points — it does not matter whether or not a number originally corresponded to a geographic x or y coordinate. These numbers do not correspond to locations on a 2D plane as far as we're concerned until such a time as they are assembled into points P1 and P2. Once you've found the values that create points P1 and P2, they are points on a 2D plane that you must find the Euclidean distance for. Your
sqrt((b-a)^2+(d-c)^2)
formula is not the Euclidean distance between points P1(a, b) and P2(c, d), which is why your formula is not correct.