
def 							__A(lowerCAmelCase						,  lowerCAmelCase )		->				Union[str, Any]:

		"""simple docstring"""






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


def 							__A(lowerCAmelCase						,  lowerCAmelCase=0 )		->				Optional[int]:

		"""simple docstring"""






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


def 							__A(lowerCAmelCase						,  lowerCAmelCase						,  lowerCAmelCase=float("""inf""" ) )		->				str:

		"""simple docstring"""






		for i in range(points_counts - 1 ):
				for j in range(i + 1						,  lowerCAmelCase ):
						_UpperCamelCase						    =	euclidean_distance_sqr(points[i]						,  points[j] )
						if current_dis < min_dis:
								_UpperCamelCase						    =	current_dis
		return min_dis


def 							__A(lowerCAmelCase						,  lowerCAmelCase						,  lowerCAmelCase=float("""inf""" ) )		->				List[Any]:

		"""simple docstring"""






		for i in range(min(6						,  points_counts - 1 )						,  lowerCAmelCase ):
				for j in range(max(0						,  i - 6 )						,  lowerCAmelCase ):
						_UpperCamelCase						    =	euclidean_distance_sqr(points[i]						,  points[j] )
						if current_dis < min_dis:
								_UpperCamelCase						    =	current_dis
		return min_dis


def 							__A(lowerCAmelCase						,  lowerCAmelCase						,  lowerCAmelCase )		->				Optional[Any]:

		"""simple docstring"""






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

		# recursion
		_UpperCamelCase						    =	points_counts // 2
		_UpperCamelCase						    =	closest_pair_of_points_sqr(
		    lowerCAmelCase						,  points_sorted_on_y[:mid]						,  lowerCAmelCase )
		_UpperCamelCase						    =	closest_pair_of_points_sqr(
		    lowerCAmelCase						,  points_sorted_on_y[mid:]						,  points_counts - mid )
		_UpperCamelCase						    =	min(lowerCAmelCase						,  lowerCAmelCase )
		_UpperCamelCase						    =	[]
		for point in points_sorted_on_x:
				if abs(point[0] - points_sorted_on_x[mid][0] ) < closest_pair_dis:
						cross_strip.append(lowerCAmelCase )

		_UpperCamelCase						    =	dis_between_closest_in_strip(
		    lowerCAmelCase						,  len(lowerCAmelCase )						,  lowerCAmelCase )
		return min(lowerCAmelCase						,  lowerCAmelCase )


def 							__A(lowerCAmelCase						,  lowerCAmelCase )		->				List[str]:

		"""simple docstring"""






		_UpperCamelCase						    =	column_based_sort(lowerCAmelCase						,  column=0 )
		_UpperCamelCase						    =	column_based_sort(lowerCAmelCase						,  column=1 )
		return (
		    closest_pair_of_points_sqr(
		        lowerCAmelCase						,  lowerCAmelCase						,  lowerCAmelCase )
		) ** 0.5


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





def 							__A(lowerCAmelCase )		->				list[list[int]]:

		"""simple docstring"""






		_UpperCamelCase						    =	[]
		if len(lowerCAmelCase ) == 1:
				return [nums.copy()]
		for _ in range(len(lowerCAmelCase ) ):
				_UpperCamelCase						    =	nums.pop(0 )
				_UpperCamelCase						    =	permute(lowerCAmelCase )
				for perm in permutations:
						perm.append(lowerCAmelCase )
				result.extend(lowerCAmelCase )
				nums.append(lowerCAmelCase )
		return result


def 							__A(lowerCAmelCase )		->				Optional[int]:

		"""simple docstring"""






		def backtrack(lowerCAmelCase ):
				if start == len(lowerCAmelCase ) - 1:
						output.append(nums[:] )
				else:
						for i in range(lowerCAmelCase						,  len(lowerCAmelCase ) ):
								_UpperCamelCase    ,	_UpperCamelCase						    =	nums[i], nums[start]
								backtrack(start + 1 )
								_UpperCamelCase    ,	_UpperCamelCase						    =	nums[i], nums[start]  # backtrack

		_UpperCamelCase						    =	[]
		backtrack(0 )
		return output


if __name__ == "__main__":
		import doctest

		# use res to print the data in permute2 function
		lowerCamelCase__	=							permutea([1, 2, 3])
		print(res)
		doctest.testmod()



