human
Minimize difference after changing all odd elements to even | Function to minimize the difference between two elements of array.
Find all the element which are possible by multiplying 2 to odd numbers.
Sort the array.
Find the minimum difference Iterate and find which adjacent elements have the minimum difference.
Print the minimum difference.
Driver Code.
Given array.
Function Call"
How can the above be solved in Python?
 Write me a code to minimize difference after changing all odd elements to even and the other steps required?
assistant
#Here is code to minimize difference after changing all odd elements to even and the other steps required.
 def minDiff ( a , n ) :
	for i in range ( n ) :
		if ( a [ i ] % 2 == 1 ) :
			a . append ( a [ i ] * 2 )
	a = sorted ( a )
	mindifference = a [ 1 ] - a [ 0 ]
	for i in range ( 1 , len ( a ) ) :
		mindifference = min ( mindifference , a [ i ] - a [ i - 1 ] )
	print ( mindifference )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 3 , 8 , 13 , 30 , 50 ]
	n = len ( arr )
	minDiff ( arr , n )