human
All unique combinations whose sum equals to K | Function to find all unique combination of given elements such that their sum is K.
If a unique combination is found.
For all other combinations.
Check if the sum exceeds K.
Check if it is repeated or not.
Take the element into the combination.
Recursive call.
Remove element from the combination.
Function to find all combination of the given elements.
Sort the given elements.
.
Driver code.
Function call"
Solution in Python:
 Give me a code to all unique combinations whose sum equals to K and the other steps required?
assistant
#Here is code to all unique combinations whose sum equals to K and the other steps required.
 def unique_combination ( l , sum , K , local , A ) :
	if ( sum == K ) :
		print ( " { " , end = " " )
		for i in range ( len ( local ) ) :
			if ( i != 0 ) :
				print ( " ▁ " , end = " " )
			print ( local [ i ] , end = " " )
			if ( i != len ( local ) - 1 ) :
				print ( " , ▁ " , end = " " )
		print ( " } " )
		return
	for i in range ( l , len ( A ) , 1 ) :
		if ( sum + A [ i ] > K ) :
			continue
		if ( i > l and A [ i ] == A [ i - 1 ] ) :
			continue
		local . append ( A [ i ] )
		unique_combination ( i + 1 , sum + A [ i ] , K , local , A )
		local . remove ( local [ len ( local ) - 1 ] )
def Combination ( A , K ) :
	A . sort ( reverse = False )
/ * To store combination * /
	local = [ ]
	unique_combination ( 0 , 0 , K , local , A )
if __name__ == ' _ _ main _ _ ' :
	A = [ 10 , 1 , 2 , 7 , 6 , 1 , 5 ]
	K = 8
	Combination ( A , K )