human
Count minimum steps to get the given desired array | Returns count of minimum operations to convert a zero array to target array with increment and doubling operations . This function computes count by doing reverse steps , i . e . , convert target to zero array ..
Initialize result ( Count of minimum moves ).
Keep looping while all elements of target don 't become 0..
To store count of zeroes in current target array.
To find first odd element.
If odd number found.
If 0 , then increment zero_count.
All numbers are 0.
All numbers are even.
Divide the whole array by 2 and increment result.
Make all odd numbers even by subtracting one and increment result ..
Driver Code"
How can the above be solved in Python?
 ... Give me a code to count minimum steps to get the given desired array and the other steps required?
assistant
#Here is code to count minimum steps to get the given desired array and the other steps required.
 def countMinOperations ( target , n ) :
	result = 0 ;
	while ( True ) :
		zero_count = 0 ;
		i = 0 ;
		while ( i < n ) :
			if ( ( target [ i ] & 1 ) > 0 ) :
				break ;
			elif ( target [ i ] == 0 ) :
				zero_count += 1 ;
			i += 1 ;
		if ( zero_count == n ) :
			return result ;
		if ( i == n ) :
			for j in range ( n ) :
				target [ j ] = target [ j ] // 2 ;
			result += 1 ;
		for j in range ( i , n ) :
			if ( target [ j ] & 1 ) :
				target [ j ] -= 1 ;
				result += 1 ;
arr = [ 16 , 16 , 16 ] ;
n = len ( arr ) ;
print ( " Minimum ▁ number ▁ of ▁ steps ▁ required ▁ to " , 	 	 " get the given target array is " , countMinOperations ( arr , n ) ) ;