human
Can you provide a code to maximum product quadruple ( sub and the other steps required given the following:
Maximum product quadruple ( sub | Function to find a maximum product of a quadruple in array of integers of size n.
if size is less than 4 , no quadruple exists.
Sort the array in ascending order.
Return the maximum of x , y and z.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to maximum product quadruple ( sub and the other steps required.
 def maxProduct ( arr , n ) :
	if ( n < 4 ) :
		return - 1
	arr . sort ( )
	x = ( arr [ n - 1 ] * arr [ n - 2 ] * arr [ n - 3 ] * arr [ n - 4 ] )
	y = arr [ 0 ] * arr [ 1 ] * arr [ 2 ] * arr [ 3 ]
	z = ( arr [ 0 ] * arr [ 1 ] * arr [ n - 1 ] * arr [ n - 2 ] )
	return max ( x , max ( y , z ) )
if __name__ == " _ _ main _ _ " :
	arr = [ - 10 , - 3 , 5 , 6 , - 20 ]
	n = len ( arr )
	max = maxProduct ( arr , n )
	if ( max == - 1 ) :
		print ( " No ▁ Quadruple ▁ Exists " )
	else :
		print ( " Maximum ▁ product ▁ is " , max )