human
Can you provide a code to find the Largest number with given number of digits and sum of digits and the other steps required given the following:
Find the Largest number with given number of digits and sum of digits | Prints the smalles possible number with digit sum ' s ' and ' m ' number of digits ..
If sum of digits is 0 , then a number is possible only if number of digits is 1..
Sum greater than the maximum possible sum ..
Create an array to store digits of result.
Fill from most significant digit to least significant digit ..
Fill 9 first to make the number largest.
If remaining sum becomes less than 9 , then fill the remaining sum.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to find the Largest number with given number of digits and sum of digits and the other steps required.
 def findLargest ( m , s ) :
	if ( s == 0 ) :
		if ( m == 1 ) :
			print ( " Largest ▁ number ▁ is ▁ " , "0" , end = " " )
		else :
			print ( " Not ▁ possible " , end = " " )
		return
	if ( s > 9 * m ) :
		print ( " Not ▁ possible " , end = " " )
		return
	res = [ 0 ] * m
	for i in range ( 0 , m ) :
		if ( s >= 9 ) :
			res [ i ] = 9
			s = s - 9
		else :
			res [ i ] = s
			s = 0
	print ( " Largest ▁ number ▁ is ▁ " , end = " " )
	for i in range ( 0 , m ) :
		print ( res [ i ] , end = " " )
s = 9
m = 2
findLargest ( m , s )