human
Count digits in given number N which divide N | Utility function to check divisibility by digit.
( N [ i ] - '0' ) gives the digit value and form the number.
Function to count digits which appears in N and divide N divide [ 10 ] -- > array which tells that particular digit divides N or not count [ 10 ] -- > counts frequency of digits which divide N.
We initialize all digits of N as not divisible by N ..
start checking divisibility of N by digits 2 to 9.
if digit divides N then mark it as true.
Now traverse the number string to find and increment result whenever a digit divides N ..
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to count digits in given number N which divide N and the other steps required.
 def divisible ( N , digit ) :
	ans = 0 ;
	for i in range ( len ( N ) ) :
		ans = ( ans * 10 + ( ord ( N [ i ] ) - ord ( '0' ) ) ) ;
		ans %= digit ;
	return ( ans == 0 ) ;
def allDigits ( N ) :
	divide = [ False ] * 10 ;
	for digit in range ( 2 , 10 ) :
		if ( divisible ( N , digit ) ) :
			divide [ digit ] = True ;
	result = 0 ;
	for i in range ( len ( N ) ) :
		if ( divide [ ( ord ( N [ i ] ) - ord ( '0' ) ) ] == True ) :
			result += 1 ;
	return result ;
N = "122324" ;
print ( allDigits ( N ) ) ;