human
Number of distinct words of size N with at most K contiguous vowels | Power function to calculate long powers with mod.
Function for finding number of ways to create string with length N and atmost K contiguous vowels.
Array dp to store number of ways.
dp [ i ] [ 0 ] = ( dp [ i - 1 ] [ 0 ] + dp [ i - 1 ] [ 1 ] . . dp [ i - 1 ] [ k ] ) * 21.
Now setting sum to be dp [ i ] [ 0 ].
If j > i , no ways are possible to create a string with length i and vowel j.
If j = i all the character should be vowel.
dp [ i ] [ j ] relation with dp [ i - 1 ] [ j - 1 ].
Adding dp [ i ] [ j ] in the sum.
Driver Code.
Input.
Function Call"
How can the above be solved in Python?

Give me a code to number of distinct words of size N with at most K contiguous vowels and the other steps required?
assistant
#Here is code to number of distinct words of size N with at most K contiguous vowels and the other steps required.
 def power ( x , y , p ) :
	res = 1
	x = x % p
	if ( x == 0 ) :
		return 0
	while ( y > 0 ) :
		if ( y & 1 ) :
			res = ( res * x ) % p
		y = y >> 1
		x = ( x * x ) % p
	return res
def kvowelwords ( N , K ) :
	i , j = 0 , 0
	MOD = 1000000007
	dp = [ [ 0 for i in range ( K + 1 ) ] for i in range ( N + 1 ) ]
	sum = 1
	for i in range ( 1 , N + 1 ) :
		dp [ i ] [ 0 ] = sum * 21
		dp [ i ] [ 0 ] %= MOD
		sum = dp [ i ] [ 0 ]
		for j in range ( 1 , K + 1 ) :
			if ( j > i ) :
				dp [ i ] [ j ] = 0
			elif ( j == i ) :
				dp [ i ] [ j ] = power ( 5 , i , MOD )
			else :
				dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] * 5
			dp [ i ] [ j ] %= MOD
			sum += dp [ i ] [ j ]
			sum %= MOD
	return sum
if __name__ == ' _ _ main _ _ ' :
	N = 3
	K = 3
	print ( kvowelwords ( N , K ) )