human
Rotate all odd numbers right and all even numbers left in an Array of 1 to N | Function to left rotate.
Function to right rotate.
Function to rotate the array.
Driver code"
Solution in Python:
assistant
#Here is code to rotate all odd numbers right and all even numbers left in an Array of 1 to N and the other steps required.
 def left_rotate ( arr ) :
	last = arr [ 1 ] ;
	for i in range ( 3 , len ( arr ) , 2 ) :
		arr [ i - 2 ] = arr [ i ]
	arr [ len ( arr ) - 1 ] = last
def right_rotate ( arr ) :
	start = arr [ len ( arr ) - 2 ]
	for i in range ( len ( arr ) - 4 , - 1 , - 2 ) :
		arr [ i + 2 ] = arr [ i ]
	arr [ 0 ] = start
def rotate ( arr ) :
	left_rotate ( arr )
	right_rotate ( arr )
	for i in range ( len ( arr ) ) :
		print ( arr [ i ] , end = " ▁ " )
arr = [ 1 , 2 , 3 , 4 , 5 , 6 ]
rotate ( arr ) ;