human
Check if all the elements can be made of same parity by inverting adjacent elements | Function to check if parity can be made same or not.
Iterate and count the parity.
Odd.
Even.
Condition check.
Driver Code"
How can the above be solved in Python?
 Can you provide a code to check if all the elements can be made of same parity by inverting adjacent elements and the other steps required?
assistant
#Here is code to check if all the elements can be made of same parity by inverting adjacent elements and the other steps required.
 def flipsPossible ( a , n ) :
	count_odd = 0 ; count_even = 0 ;
	for i in range ( n ) :
		if ( a [ i ] & 1 ) :
			count_odd += 1 ;
		else :
			count_even += 1 ;
	if ( count_odd % 2 and count_even % 2 ) :
		return False ;
	else :
		return True ;
if __name__ == " _ _ main _ _ " :
	a = [ 1 , 0 , 1 , 1 , 0 , 1 ] ;
	n = len ( a ) ;
	if ( flipsPossible ( a , n ) ) :
		print ( " Yes " ) ;
	else :
		print ( " No " ) ;