human
Next greater Number than N with the same quantity of digits A and B | Recursive function to find the required number.
If the resulting number is >= n and count of a = count of b , return the number.
select minimum of two and call the function again.
Function to find the number next greater Number than N with the same quantity of digits A and B.
Driver code"
How can the above be solved in Python?
 ... Write me a code to next greater Number than N with the same quantity of digits A and B and the other steps required?
assistant
#Here is code to next greater Number than N with the same quantity of digits A and B and the other steps required.
 def findNumUtil ( res , a , aCount , b , bCount , n ) :
	if ( res > 1e11 ) :
		return 1e11
	if ( aCount == bCount and res >= n ) :
		return res
	return min ( findNumUtil ( res * 10 + a , a , aCount + 1 , b , bCount , n ) , findNumUtil ( res * 10 + b , a , aCount , b , bCount + 1 , n ) )
def findNum ( n , a , b ) :
	result = 0
	aCount = 0
	bCount = 0
	return findNumUtil ( result , a , aCount , b , bCount , n )
if __name__ == ' _ _ main _ _ ' :
	N = 4500
	A = 4
	B = 7
	print ( findNum ( N , A , B ) )