human
Give me a code to count numbers in range such that digits in it and it 's product with q are unequal and the other steps required given the following:
Count numbers in range such that digits in it and it 's product with q are unequal | Function to check if all of the digits in a number and it 's product with q are unequal or not.
convert first number into string.
Insert elements from 1 st number to hash.
Calculate corresponding product.
Convert the product to string.
Using the hash check if any digit of product matches with the digits of input number.
If yes , return false.
Return true.
Function to count numbers in the range [ l , r ] such that all of the digits of the number and it 's product with q are unequal.
check for every number between l and r.
Driver Code.
Function call"
Solution in Python:
assistant
#Here is code to count numbers in range such that digits in it and it 's product with q are unequal and the other steps required.
 def checkIfUnequal ( n , q ) :
	s1 = str ( n )
	a = [ 0 for i in range ( 26 ) ]
	for i in range ( 0 , len ( s1 ) , 1 ) :
		a [ ord ( s1 [ i ] ) - ord ( '0' ) ] += 1
	prod = n * q
	s2 = str ( prod )
	for i in range ( 0 , len ( s2 ) , 1 ) :
		if ( a [ ord ( s2 [ i ] ) - ord ( '0' ) ] ) :
			return False
	return True
def countInRange ( l , r , q ) :
	count = 0
	for i in range ( l , r + 1 , 1 ) :
		if ( checkIfUnequal ( i , q ) ) :
			count += 1
	return count
if __name__ == ' _ _ main _ _ ' :
	l = 10
	r = 12
	q = 2
	print ( countInRange ( l , r , q ) )