fill columns with coordinates
for x , y in A : NEW_LINE INDENT columns [ x ] . append ( y ) NEW_LINE DEDENT lastx = { } NEW_LINE ans = float ( ' inf ' ) NEW_LINE for x in sorted ( columns ) : NEW_LINE INDENT column = columns [ x ] NEW_LINE column . sort ( ) NEW_LINE for j , y2 in enumerate ( column ) : NEW_LINE INDENT for i in range ( j ) : NEW_LINE INDENT y1 = column [ i ] NEW_LINE DEDENT DEDENT DEDENT