human
Number of subsets with sum divisible by m | Use Dynamic Programming to find sum of subsequences ..
Find sum pf array elements.
dp [ i ] [ j ] would be > 0 if arr [ 0. . i - 1 ] has a subsequence with sum equal to j ..
There is always sum equals zero.
Fill up the dp table.
Initialize the counter.
Check if the sum exists.
check sum is divisible by m.
Driver Code"
How can the above be solved in Python?
 ... Can you provide a code to number of subsets with sum divisible by m and the other steps required?
assistant
#Here is code to number of subsets with sum divisible by m and the other steps required.
 def sumSubSequence ( arr , length , m ) :
	summ = 0
	for i in arr :
		summ += i
	dp = [ [ 0 for i in range ( summ + 1 ) ] for j in range ( length + 1 ) ]
	for i in range ( length + 1 ) :
		dp [ i ] [ 0 ] += 1
	for i in range ( 1 , length + 1 ) :
		dp [ i ] [ arr [ i - 1 ] ] += 1
		for j in range ( 1 , summ + 1 ) :
			if dp [ i - 1 ] [ j ] > 0 :
				dp [ i ] [ j ] += 1
				dp [ i ] [ j + arr [ i - 1 ] ] += 1
	count = 0
	for i in range ( 1 , summ + 1 ) :
		if dp [ length ] [ i ] > 0 :
			if i % m == 0 :
				count += dp [ length ] [ i ]
	return count
if __name__ == " _ _ main _ _ " :
	arr = [ 1 , 2 , 3 ]
	m = 3
	length = len ( arr )
	print ( sumSubSequence ( arr , length , m ) )