human
Find the subsequence with given sum in a superincreasing sequence | Function to find the required subsequence.
Current element cannot be a part of the required subsequence.
Include current element in the required subsequence So update the sum.
Print the elements of the required subsequence.
If the current element was included in the subsequence.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to find the subsequence with given sum in a superincreasing sequence and the other steps required.
 def findSubSeq ( arr , n , sum ) :
	for i in range ( n - 1 , - 1 , - 1 ) :
		if ( sum < arr [ i ] ) :
			arr [ i ] = - 1 ;
		else :
			sum -= arr [ i ] ;
	for i in range ( n ) :
		if ( arr [ i ] != - 1 ) :
			print ( arr [ i ] , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
	arr = [ 17 , 25 , 46 , 94 , 201 , 400 ] ;
	n = len ( arr ) ;
	sum = 272 ;
	findSubSeq ( arr , n , sum ) ;