FunctionRacerProblemsRace

Two Closest Points

HardNumPyPython

Each row of points is a point (x, y). Return [i, j] with i < j: the rows of the two points closest together. If pairs tie, return the pair with the smallest i, then the smallest j. No loops: for and while are not allowed.

Example 1

points [[0,0],[5,5],[1,1],[9,0]]
returns [0,2]

Points 0 and 2 are about 1.41 apart. No other pair is closer.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems