human
Find smallest number with given digits and sum of digits | Function to print minimum integer having only digits P and Q and the sum of digits as N.
If Q is greater that P then swap the values of P and Q.
If P and Q are both zero or if Q is zero and N is not divisible by P then there is no possible integer which satisfies the given conditions.
Loop to find the maximum value of count_P that also satisfy P * count_P + Q * count_Q = N.
If N is 0 , their is a valid integer possible that satisfies all the requires conditions.
Print Answer.
Driver Code.
Function Call"
Solution in Python:
assistant
#Here is code to find smallest number with given digits and sum of digits and the other steps required.
 def printMinInteger ( P , Q , N ) :
	if ( Q > P ) :
		t = P
		P = Q
		Q = t
	if ( Q == 0 and ( P == 0 or N % P != 0 ) ) :
		print ( " Not ▁ Possible " )
		return
	count_P = 0
	count_Q = 0
	while ( N > 0 ) :
		if ( N % P == 0 ) :
			count_P += N / P
			N = 0
		else :
			N = N - Q
			count_Q += 1
	if ( N == 0 ) :
		for i in range ( count_Q ) :
			print ( Q , end = " " )
		for i in range ( int ( count_P ) ) :
			print ( P , end = " " )
	else :
		print ( " Not ▁ Possible " )
N = 32
P = 7
Q = 4
printMinInteger ( P , Q , N )