human
Minimum number of flipping adjacent bits required to make given Binary Strings equal | Function to find the minimum number of inversions required ..
Initializing the answer.
Iterate over the range.
If s1 [ i ] != s2 [ i ] , then inverse the characters at i snd ( i + 1 ) positions in s1 ..
Adding 1 to counter if characters are not same.
Driver Code"
How can the above be solved in Python?
 What is a code to minimum number of flipping adjacent bits required to make given Binary Strings equal and the other steps required?
assistant
#Here is code to minimum number of flipping adjacent bits required to make given Binary Strings equal and the other steps required.
 def find_Min_Inversion ( n , s1 , s2 ) :
	count = 0
	s1 = list ( s1 )
	s2 = list ( s2 )
	for i in range ( n - 1 ) :
		if ( s1 [ i ] != s2 [ i ] ) :
			if ( s1 [ i ] == '1' ) :
				s1 [ i ] = '0'
			else :
				s1 [ i ] = '1'
			if ( s1 [ i + 1 ] == '1' ) :
				s1 [ i + 1 ] = '0'
			else :
				s1 [ i + 1 ] = '1'
			count += 1
	s1 = ' ' . join ( s1 )
	s2 = ' ' . join ( s2 )
	if ( s1 == s2 ) :
		return count
	return - 1
if __name__ == ' _ _ main _ _ ' :
	n = 4
	s1 = "0101"
	s2 = "1111"
	print ( find_Min_Inversion ( n , s1 , s2 ) )