@@ -73,8 +73,8 @@ def dis_between_closest_in_strip(points, points_counts, min_dis=float("inf")):
7373 85
7474 """
7575
76- for i in range (min ( 6 , points_counts - 1 ), points_counts ):
77- for j in range (max ( 0 , i - 6 ), i ):
76+ for i in range (points_counts - 1 ):
77+ for j in range (i + 1 , min ( i + 6 , points_counts ) ):
7878 current_dis = euclidean_distance_sqr (points [i ], points [j ])
7979 if current_dis < min_dis :
8080 min_dis = current_dis
@@ -101,10 +101,10 @@ def closest_pair_of_points_sqr(points_sorted_on_x, points_sorted_on_y, points_co
101101 # recursion
102102 mid = points_counts // 2
103103 closest_in_left = closest_pair_of_points_sqr (
104- points_sorted_on_x , points_sorted_on_y [:mid ], mid
104+ points_sorted_on_x [:mid ], points_sorted_on_y , mid
105105 )
106106 closest_in_right = closest_pair_of_points_sqr (
107- points_sorted_on_y , points_sorted_on_y [mid :], points_counts - mid
107+ points_sorted_on_x [mid :], points_sorted_on_y , points_counts - mid
108108 )
109109 closest_pair_dis = min (closest_in_left , closest_in_right )
110110
@@ -114,7 +114,7 @@ def closest_pair_of_points_sqr(points_sorted_on_x, points_sorted_on_y, points_co
114114 """
115115
116116 cross_strip = []
117- for point in points_sorted_on_x :
117+ for point in points_sorted_on_y :
118118 if abs (point [0 ] - points_sorted_on_x [mid ][0 ]) < closest_pair_dis :
119119 cross_strip .append (point )
120120
0 commit comments