human
Digitally balanced numbers | Function to check if the digits in the number is the same number of digits.
Loop to iterate over the digits of the number N.
Loop to iterate over the map.
Driver code.
Function to check"
Solution in Python:
assistant
#Here is code to digitally balanced numbers and the other steps required.
 def checkSame ( n , b ) :
	m = { }
	while ( n != 0 ) :
		r = n % b
		n = n // b
		if r in m :
			m [ r ] += 1
		else :
			m [ r ] = 1
	last = - 1
	for i in m :
		if last != - 1 and m [ i ] != last :
			return False
		else :
			last = m [ i ]
	return True
n = 9
base = 2
if ( checkSame ( n , base ) ) :
	print ( " Yes " )
else :
	print ( " NO " )