human
Count ways to split array into two subsets having difference between their sum equal to K | Function to count the number of ways to divide the array into two subsets and such that the difference between their sums is equal to diff.
Store the sum of the set S1.
Initializing the matrix.
Number of ways to get sum using 0 elements is 0.
Number of ways to get sum 0 using i elements is 1.
Traverse the 2D array.
If the value is greater than the sum store the value of previous state.
Return the result.
Driver Code.
Given Input.
Function Call"
Solution in Python:

Give me a code to count ways to split array into two subsets having difference between their sum equal to K and the other steps required?
assistant
#Here is code to count ways to split array into two subsets having difference between their sum equal to K and the other steps required.
 def countSubset ( arr , n , diff ) :
	sum = 0
	for i in range ( n ) :
		sum += arr [ i ]
	sum += diff
	sum = sum // 2
	t = [ [ 0 for i in range ( sum + 1 ) ] for i in range ( n + 1 ) ]
	for j in range ( sum + 1 ) :
		t [ 0 ] [ j ] = 0
	for i in range ( n + 1 ) :
		t [ i ] [ 0 ] = 1
	for i in range ( 1 , n + 1 ) :
		for j in range ( 1 , sum + 1 ) :
			if ( arr [ i - 1 ] > j ) :
				t [ i ] [ j ] = t [ i - 1 ] [ j ]
			else :
				t [ i ] [ j ] = t [ i - 1 ] [ j ] + t [ i - 1 ] [ j - arr [ i - 1 ] ]
	return t [ n ] [ sum ]
if __name__ == ' _ _ main _ _ ' :
	diff , n = 1 , 4
	arr = [ 1 , 1 , 2 , 3 ]
	print ( countSubset ( arr , n , diff ) )