human
Print all the combinations of N elements by changing sign such that their sum is divisible by M | Function to print all the combinations.
Iterate for all combinations.
Initially 100 in binary if n is 3 as 1 << ( 3 - 1 ) = 100 in binary.
Iterate in the array and assign signs to the array elements.
If the j - th bit from left is set take ' + ' sign.
Right shift to check if jth bit is set or not.
re - initialize.
Iterate in the array elements.
If the jth from left is set.
right shift.
Driver code"
Solution in Python:

Can you provide a code to print all the combinations of N elements by changing sign such that their sum is divisible by M and the other steps required?
assistant
#Here is code to print all the combinations of N elements by changing sign such that their sum is divisible by M and the other steps required.
 def printCombinations ( a , n , m ) :
	for i in range ( 0 , ( 1 << n ) ) :
		sum = 0
		num = 1 << ( n - 1 )
		for j in range ( 0 , n ) :
			if ( ( i & num ) > 0 ) :
				sum += a [ j ]
			else :
				sum += ( - 1 * a [ j ] )
			num = num >> 1
		if ( sum % m == 0 ) :
			num = 1 << ( n - 1 )
			for j in range ( 0 , n ) :
				if ( ( i & num ) > 0 ) :
					print ( " + " , a [ j ] , end = " ▁ " , sep = " " )
				else :
					print ( " - " , a [ j ] , end = " ▁ " , sep = " " )
				num = num >> 1
			print ( " " )
a = [ 3 , 5 , 6 , 8 ]
n = len ( a )
m = 5
printCombinations ( a , n , m )