human
Smallest Difference Triplet from Three arrays | Function to find maximum number.
Function to find minimum number.
Finds and prints the smallest Difference Triplet.
sorting all the three arrays.
To store resultant three numbers.
pointers to arr1 , arr2 , arr3 respectively.
Loop until one array reaches to its end Find the smallest difference ..
maximum number.
Find minimum and increment its index ..
Comparing new difference with the previous one and updating accordingly.
Print result.
Driver code"
Solution in Python:
 Can you provide a code to smallest Difference Triplet from Three arrays and the other steps required?
assistant
#Here is code to smallest Difference Triplet from Three arrays and the other steps required.
 def maximum ( a , b , c ) :
	return max ( max ( a , b ) , c )
def minimum ( a , b , c ) :
	return min ( min ( a , b ) , c )
def smallestDifferenceTriplet ( arr1 , arr2 , arr3 , n ) :
	arr1 . sort ( )
	arr2 . sort ( )
	arr3 . sort ( )
	res_min = 0 ; res_max = 0 ; res_mid = 0
	i = 0 ; j = 0 ; k = 0
	diff = 2147483647
	while ( i < n and j < n and k < n ) :
		sum = arr1 [ i ] + arr2 [ j ] + arr3 [ k ]
		max = maximum ( arr1 [ i ] , arr2 [ j ] , arr3 [ k ] )
		min = minimum ( arr1 [ i ] , arr2 [ j ] , arr3 [ k ] )
		if ( min == arr1 [ i ] ) :
			i += 1
		elif ( min == arr2 [ j ] ) :
			j += 1
		else :
			k += 1
		if ( diff > ( max - min ) ) :
			diff = max - min
			res_max = max
			res_mid = sum - ( max + min )
			res_min = min
	print ( res_max , " , " , res_mid , " , " , res_min )
arr1 = [ 5 , 2 , 8 ]
arr2 = [ 10 , 7 , 12 ]
arr3 = [ 9 , 14 , 6 ]
n = len ( arr1 )
smallestDifferenceTriplet ( arr1 , arr2 , arr3 , n )