


"""simple docstring"""
def 				_snake_case      (   __snake_case							:      Any						, __snake_case							:      Dict   ):




   """simple docstring"""







   return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2

def 				_snake_case      (   __snake_case							:      str						, __snake_case							:      List[str]=0   ):




   """simple docstring"""







   return sorted(__snake_case						, key=lambda __snake_case   : x[column]   )

def 				_snake_case      (   __snake_case							:      List[Any]						, __snake_case							:      Dict						, __snake_case							:      Optional[Any]=float("""inf"""   )   ):




   """simple docstring"""







   for i in range(points_counts - 1   ):
      for j in range(i + 1						, __snake_case   ):
         _lowerCamelCase	:					str   =		euclidean_distance_sqr(points[i]						, points[j]   )
         if current_dis < min_dis:
            _lowerCamelCase	:					Optional[Any]   =		current_dis
   return min_dis

def 				_snake_case      (   __snake_case							:      List[Any]						, __snake_case							:      Dict						, __snake_case							:      List[str]=float("""inf"""   )   ):




   """simple docstring"""







   for i in range(min(6						, points_counts - 1   )						, __snake_case   ):
      for j in range(max(0						, i - 6   )						, __snake_case   ):
         _lowerCamelCase	:					Optional[int]   =		euclidean_distance_sqr(points[i]						, points[j]   )
         if current_dis < min_dis:
            _lowerCamelCase	:					str   =		current_dis
   return min_dis

def 				_snake_case      (   __snake_case							:      Tuple						, __snake_case							:      Optional[Any]						, __snake_case							:      Any   ):




   """simple docstring"""







   if points_counts <= 3:
      return dis_between_closest_pair(__snake_case						, __snake_case   )

   # recursion
   _lowerCamelCase	:					Optional[int]   =		points_counts // 2
   _lowerCamelCase	:					List[Any]   =		closest_pair_of_points_sqr(
       __snake_case						, points_sorted_on_y[:mid]						, __snake_case   )
   _lowerCamelCase	:					Any   =		closest_pair_of_points_sqr(
       __snake_case						, points_sorted_on_y[mid:]						, points_counts - mid   )
   _lowerCamelCase	:					str   =		min(__snake_case						, __snake_case   )
   _lowerCamelCase	:					Optional[Any]   =		[]
   for point in points_sorted_on_x:
      if abs(point[0] - points_sorted_on_x[mid][0]   ) < closest_pair_dis:
         cross_strip.append(__snake_case   )

   _lowerCamelCase	:					List[str]   =		dis_between_closest_in_strip(
       __snake_case						, len(__snake_case   )						, __snake_case   )
   return min(__snake_case						, __snake_case   )

def 				_snake_case      (   __snake_case							:      List[Any]						, __snake_case							:      int   ):




   """simple docstring"""







   _lowerCamelCase	:					Dict   =		column_based_sort(__snake_case						, column=0   )
   _lowerCamelCase	:					List[str]   =		column_based_sort(__snake_case						, column=1   )
   return (
       closest_pair_of_points_sqr(
           __snake_case						, __snake_case						, __snake_case   )
   ) ** 0.5


if __name__ == "__main__":
 UpperCAmelCase				=						[(2, 3), (12, 30), (40, 50), (5, 1), (12, 10), (3, 4)]
 print("""Distance:""", closest_pair_of_points(points, len(points)))





"""simple docstring"""
def 				_snake_case      (   __snake_case							:      list[list[int]]						, __snake_case							:      int						, __snake_case							:      int						, __snake_case							:      list[int]   ):




   """simple docstring"""







   if graph[path[curr_ind - 1]][next_ver] == 0:
      return False

   # 2. Validate that next vertex is not already in path
   return not any(vertex == next_ver for vertex in path   )

def 				_snake_case      (   __snake_case							:      list[list[int]]						, __snake_case							:      list[int]						, __snake_case							:      int   ):




   """simple docstring"""







   if curr_ind == len(__snake_case   ):
      # return whether path exists between current and starting vertices
      return graph[path[curr_ind - 1]][path[0]] == 1

   # Recursive Step
   for next_ver in range(0						, len(__snake_case   )   ):
      if valid_connection(__snake_case						, __snake_case						, __snake_case						, __snake_case   ):
         # Insert current vertex  into path as next transition
         _lowerCamelCase	:					List[str]   =		next_ver
         # Validate created path
         if util_hamilton_cycle(__snake_case						, __snake_case						, curr_ind + 1   ):
            return True
         # Backtrack
         _lowerCamelCase	:					Tuple   =		-1
   return False





def 				_snake_case      (   __snake_case							:      list[list[int]]						, __snake_case							:      int = 0   ):




   """simple docstring"""







   _lowerCamelCase	:					Any   =		[-1] * (len(__snake_case   ) + 1)
   # initialize start and end of path with starting index
   _lowerCamelCase	:					Optional[int]   =		start_index
   # evaluate and if we find answer return path either return empty array
   return path if util_hamilton_cycle(__snake_case						, __snake_case						, 1   ) else []

