human
Minimum number of elements to add to make median equals x | Returns count of elements to be added to make median x . This function assumes that a [ ] has enough extra space ..
to sort the array in increasing order ..
Driver code"
How can the above be solved in Python?
 ... Write me a code to minimum number of elements to add to make median equals x and the other steps required?
assistant
#Here is code to minimum number of elements to add to make median equals x and the other steps required.
 def minNumber ( a , n , x ) :
	a . sort ( reverse = False )
	k = 0
	while ( a [ int ( ( n - 1 ) / 2 ) ] != x ) :
		a [ n - 1 ] = x
		n += 1
		a . sort ( reverse = False )
		k += 1
	return k
if __name__ == ' _ _ main _ _ ' :
	x = 10
	a = [ 10 , 20 , 30 ]
	n = 3
	print ( minNumber ( a , n , x ) )