human
Print a number strictly less than a given number such that all its digits are distinct . | Function to find a number less than n such that all its digits are distinct.
looping through numbers less than n.
initializing a hash array.
creating a copy of i.
initializing variables to compare lengths of digits.
counting frequency of the digits.
checking if each digit is present once.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to print a number strictly less than a given number such that all its digits are distinct .
 def findNumber ( n ) :
	i = n - 1
	while ( i >= 0 ) :
		count = [ 0 for i in range ( 10 ) ]
		x = i
		count1 = 0
		count2 = 0
		while ( x ) :
			count [ x % 10 ] += 1
			x = int ( x / 10 )
			count1 += 1
		for j in range ( 0 , 10 , 1 ) :
			if ( count [ j ] == 1 ) :
				count2 += 1
		if ( count1 == count2 ) :
			return i
		i -= 1
if __name__ == ' _ _ main _ _ ' :
	n = 8490
	print ( findNumber ( n ) )