human
Minimum cost to make all array elements equal | Function to return the minimum cost to make each array element equal.
To store the count of even numbers present in the array.
To store the count of odd numbers present in the array.
Iterate through the array and find the count of even numbers and odd numbers.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to minimum cost to make all array elements equal and the other steps required.
 def minCost ( arr , n ) :
	count_even = 0
	count_odd = 0
	for i in range ( n ) :
		if ( arr [ i ] % 2 == 0 ) :
			count_even += 1
		else :
			count_odd += 1
	return min ( count_even , count_odd )
arr = [ 2 , 4 , 3 , 1 , 5 ]
n = len ( arr )
print ( minCost ( arr , n ) )