human
Pair formation such that maximum pair sum is minimized | Python 3 Program to divide the array into N pairs such that maximum pair is minimized.
After Sorting Maintain two variables i and j pointing to start and end of array Such that smallest element of array pairs with largest element.
Driver Code"
Solution in Python:
 ... Write me a code to pair formation such that maximum pair sum is minimized and the other steps required?
assistant
#Here is code to pair formation such that maximum pair sum is minimized and the other steps required.
 def findOptimalPairs ( arr , N ) :
	arr . sort ( reverse = False )
	i = 0
	j = N - 1
	while ( i <= j ) :
		print ( " ( " , arr [ i ] , " , " , arr [ j ] , " ) " , end = " ▁ " )
		i += 1
		j -= 1
if __name__ == ' _ _ main _ _ ' :
	arr = [ 9 , 6 , 5 , 1 ]
	N = len ( arr )
	findOptimalPairs ( arr , N )