human
Minimum steps to convert one binary string to other only using negation | Function to find the minimum steps to convert string a to string b.
List to mark the positions needed to be negated.
If two character are not same then they need to be negated.
To count the blocks of 1.
To count the number of 1 ' s ▁ in ▁ each ▁ ▁ block ▁ of ▁ 1' s.
For the last block of 1 's.
Driver code"
How can the above be solved in Python?
 Give me a code to minimum steps to convert one binary string to other only using negation and the other steps required?
assistant
#Here is code to minimum steps to convert one binary string to other only using negation and the other steps required.
 def convert ( n , a , b ) :
	l = [ 0 ] * n
	for i in range ( n ) :
		if ( a [ i ] != b [ i ] ) :
			l [ i ] = 1
	cc = 0
	vl = 0
	for i in range ( n ) :
		if ( l [ i ] == 0 ) :
			if ( vl != 0 ) :
				cc += 1
			vl = 0
		else :
			vl += 1
	if ( vl != 0 ) :
		cc += 1
	print ( cc )
a = "101010"
b = "110011"
n = len ( a )
convert ( n , a , b )