human
Three way partitioning of an array around a given range | Partitions arr [ 0. . n - 1 ] around [ lowVal . . highVal ].
Initialize ext available positions for smaller ( than range ) and greater lements.
Traverse elements from left.
If current element is smaller than range , put it on next available smaller position ..
If current element is greater than range , put it on next available greater position ..
Driver code"
How can the above be solved in Python?
 What is a code to three way partitioning of an array around a given range and the other steps required?
assistant
#Here is code to three way partitioning of an array around a given range and the other steps required.
 def threeWayPartition ( arr , n , lowVal , highVal ) :
	start = 0
	end = n - 1
	i = 0
	while i <= end :
		if arr [ i ] < lowVal :
			temp = arr [ i ]
			arr [ i ] = arr [ start ]
			arr [ start ] = temp
			i += 1
			start += 1
		elif arr [ i ] > highVal :
			temp = arr [ i ]
			arr [ i ] = arr [ end ]
			arr [ end ] = temp
			end -= 1
		else :
			i += 1
if __name__ == " _ _ main _ _ " :
	arr = [ 1 , 14 , 5 , 20 , 4 , 2 , 54 , 20 , 87 , 98 , 3 , 1 , 32 ]
	n = len ( arr )
	threeWayPartition ( arr , n , 10 , 20 )
	print ( " Modified ▁ array " )
	for i in range ( n ) :
		print ( arr [ i ] , end = " ▁ " )