human
Move weighting scale alternate under given constraints | DFS method to traverse among states of weighting scales.
If we reach to more than required steps , return true.
Try all possible weights and choose one which returns 1 afterwards.
Try this weight only if it is greater than current residueand not same as previous chosen weight.
assign this weight to array and recur for next state.
if any weight is not possible , return false.
method prints weights for alternating scale and if not possible prints ' not ▁ possible '.
call dfs with current residue as 0 and current steps as 0.
Driver Code"
Solution in Python:
 Give me a code to move weighting scale alternate under given constraints and the other steps required?
assistant
#Here is code to move weighting scale alternate under given constraints and the other steps required.
 def dfs ( residue , curStep , wt , arr , N , steps ) :
	if ( curStep >= steps ) :
		return True
	for i in range ( N ) :
		if ( arr [ i ] > residue and arr [ i ] != wt [ curStep - 1 ] ) :
			wt [ curStep ] = arr [ i ]
			if ( dfs ( arr [ i ] - residue , curStep + 1 , wt , arr , N , steps ) ) :
				return True
	return False
def printWeightsOnScale ( arr , N , steps ) :
	wt = [ 0 ] * ( steps )
	if ( dfs ( 0 , 0 , wt , arr , N , steps ) ) :
		for i in range ( steps ) :
			print ( wt [ i ] , end = " ▁ " )
	else :
		print ( " Not ▁ possible " )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 2 , 3 , 5 , 6 ]
	N = len ( arr )
	steps = 10
	printWeightsOnScale ( arr , N , steps )