// Seed the result - doesn't matter what points are used// This just avoids having to do null checks in the main loop belowvar result =new Segment(points[0], points[1]);var bestLength = result.Length();

Targeted Search: Much simpler than divide and conquer, and actually runs faster for the random points. Key optimization is that if the distance along the X axis is greater than the best total length you already have, you can terminate the inner loop early. However, as only sorts in the X direction, it degenerates into an N^2 algorithm if all the points have the same X.

Elegant (divide-and-conquer reduction) solution. Incorporates X-only and Y-only pre-checks in two places (four if you count the inclusion of the brute force solution) to cut down on the square root calculations:

The solution presented here is essentially a direct translation into jq of the pseudo-code presented in the task description,
but "closest_pair" is added so that any list of [x,y] points can be presented, and extra lines are added to ensure that xL and yL have the same lengths.

Infrastructure:

# This definition of "until" is included in recent versions (> 1.4) of jq# Emit the first input that satisfied the conditiondef until(cond; next): def _until: if cond then . else (next|_until) end; _until;

The brute force algorithm is easy.
Reading from left to right, clop is defined as a function
that forms the Cartesian product of its argument,
and then extracts the member whose left side is a minimum
with respect to the floating point comparison relation
after deleting equal pairs and attaching to the left of
each remaining pair the sum of the squares of the differences
between corresponding coordinates.

#import flo

clop = @iiK0 fleq$-&l+ *EZF ^\~& plus+ sqr~~+ minus~~bbI

The divide and conquer algorithm following the specification
given above is a little more hairy but not much longer.
The eudist library function
is used to compute the distance between points.