human
Count of N | Function to return count of N - digit numbers with absolute difference of adjacent digits not exceeding K.
For 1 - digit numbers , the count is 10.
dp [ i ] [ j ] stores the count of i - digit numbers ending with j.
Initialize count for 1 - digit numbers.
Compute values for count of digits greater than 1.
Find the range of allowed numbers if last digit is j.
Perform Range update.
Prefix sum to find count of of i - digit numbers ending with j.
Stores the final answer.
Driver Code"
How can the above be solved in Python?
 ... Can you provide a code to count of N and the other steps required?
assistant
#Here is code to count of N and the other steps required.
 def getCount ( n , k ) :
	if n == 1 :
		return 10
	dp = [ [ 0 for x in range ( 11 ) ] for y in range ( n + 1 ) ] ;
	for i in range ( 1 , 10 ) :
		dp [ 1 ] [ i ] = 1
	for i in range ( 2 , n + 1 ) :
		for j in range ( 0 , 10 ) :
			l = max ( 0 , j - k )
			r = min ( 9 , j + k )
			dp [ i ] [ l ] = dp [ i ] [ l ] + dp [ i - 1 ] [ j ]
			dp [ i ] [ r + 1 ] = dp [ i ] [ r + 1 ] - dp [ i - 1 ] [ j ]
		for j in range ( 1 , 10 ) :
			dp [ i ] [ j ] = dp [ i ] [ j ] + dp [ i ] [ j - 1 ]
	count = 0
	for i in range ( 0 , 10 ) :
		count = count + dp [ n ] [ i ]
	return count
n , k = 2 , 1
print ( getCount ( n , k ) )