a dynamic programming based python3 program to partition problem returns true if arr can be partitioned in two subsets of equal sum otherwise false calculate sum of all elements initialize the part array as 0 fill the partition table in bottom up manner the element to be included in the sum cannot be greater than the sum check if sum arri could be formed from a subset using elements before index i drive code function call a dynamic programming based python3 program to partition problem returns true if arr can be partitioned in two subsets of equal sum otherwise false calculate sum of all elements initialize the part array as 0 fill the partition table in bottom up manner the element to be included in the sum cannot be greater than the sum check if sum arr i could be formed from a subset using elements before index i drive code function call
def find_partiion(arr, n) :
	sum = 0

	
	for i in range(n) :
		sum += arr[i]
	if (sum % 2 != 0) :
		return 0
	part = [0] * ((sum // 2) + 1)

	
	for i in range((sum // 2) + 1) :
		part[i] = 0

	
	for i in range(n) :
	
		
		
		
		for j in range(sum // 2, arr[i] - 1, -1) :
		
			
			
			
			
			
			if (part[j - arr[i]] == 1 or j == arr[i]) :
				part[j] = 1

	return part[sum // 2]


arr = [ 1, 3, 3, 2, 3, 2 ]
n = len(arr)


if (find_partiion(arr, n) == 1) :
	print("Can be divided into two subsets of equal sum")
else :
	print("Can not be divided into two subsets of equal sum")