human
Permutation of Array such that products of all adjacent elements are even | Function to print the required permutation.
push odd elements in ' odd ' and even elements in 'even.
Check if it possible to arrange the elements.
else print the permutation.
Print remaining odds are even . and even elements.
Driver Code"
How can the above be solved in Python?
 ... Write me a code to permutation of Array such that products of all adjacent elements are even and the other steps required?
assistant
#Here is code to permutation of Array such that products of all adjacent elements are even and the other steps required.
 def printPermutation ( arr , n ) :
	odd , even = [ ] , [ ]
'
	for i in range ( n ) :
		if ( arr [ i ] % 2 == 0 ) :
			even . append ( arr [ i ] )
		else :
			odd . append ( arr [ i ] )
	size_odd = len ( odd )
	size_even = len ( even )
	if ( size_odd > size_even + 1 ) :
		print ( - 1 )
	else :
		i , j = 0 , 0
		while ( i < size_odd and j < size_even ) :
			print ( odd [ i ] , end = " ▁ " )
			i += 1
			print ( even [ j ] , end = " ▁ " )
			j += 1
	while ( i < size_odd ) :
		print ( odd [ i ] , end = " ▁ " )
		i += 1
	while ( j < size_even ) :
		print ( even [ j ] , end = " ▁ " )
		j += 1
arr = [ 6 , 7 , 9 , 8 , 10 , 11 ]
N = len ( arr )
printPermutation ( arr , N )