6 kyu
Closest pair of points
357kirjs
Description:
Given a number of points on a plane, your task is to find two points with the smallest distance between them.
Each points will be represented as an array with 2 coordinates.
Example
1 2 3 4 5 6 7 8 9
1
2 . A
3 . D
4 . F
5 . C
6
7 . E
8 . B
9 . G
For the plane above, the input will be:
[
[2,2], // A
[2,8], // B
[5,5], // C
[6,3], // D
[6,7], // E
[7,4], // F
[7,8] // G
]
The two points that are closest to each other are D and F. Expected answer should be an array with both points in any order. [[6,3],[7,4]] or [[7,4],[6,3]] are valid answers for the example above.
More information on http://en.wikipedia.org/wiki/Closest_pair_of_points_problem
Algorithms
Similar Kata:
Stats:
Created | May 16, 2014 |
Published | May 16, 2014 |
Warriors Trained | 787 |
Total Skips | 59 |
Total Code Submissions | 2594 |
Total Times Completed | 357 |
JavaScript Completions | 357 |
Total Stars | 24 |
% of votes with a positive feedback rating | 91% of 116 |
Total "Very Satisfied" Votes | 97 |
Total "Somewhat Satisfied" Votes | 16 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 21 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |