Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants | Function to returns factorial of n ; Function to find nCr ; Function to find the number of words of X vowels and Y consonants can be formed from M vowels and N consonants ; Driver code ; Function call
def fact ( n ) : NEW_LINE INDENT res = 1 NEW_LINE for i in range ( 2 , n + 1 , 1 ) : NEW_LINE INDENT res = res * i NEW_LINE DEDENT return res NEW_LINE DEDENT def nCr ( n , r ) : NEW_LINE INDENT return fact ( n ) // ( fact ( r ) * fact ( n - r ) ) NEW_LINE DEDENT def NumberOfWays ( X , Y , M , N ) : NEW_LINE INDENT return fact ( X + Y ) * nCr ( M , X ) * nCr ( N , Y ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT X = 2 NEW_LINE Y = 2 NEW_LINE M = 3 NEW_LINE N = 3 NEW_LINE print ( NumberOfWays ( X , Y , M , N ) ) NEW_LINE DEDENT