Count of ways to rearrange N digits and M alphabets keeping all alphabets together | Python program of the above approach ; Function to find the factorial of the given number ; Function to count ways to rearrange characters of the string such that all alphabets are adjacent . ; Stores factorial of ( N + 1 ) ; Stores factorial of ; Driver Code ; Given a and b ; Function call
import math NEW_LINE def fact ( a ) : NEW_LINE INDENT return math . factorial ( a ) NEW_LINE DEDENT def findComb ( N , M ) : NEW_LINE INDENT x = fact ( N + 1 ) NEW_LINE y = fact ( M ) NEW_LINE return ( x * y ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 2 NEW_LINE M = 2 NEW_LINE print ( findComb ( N , M ) ) NEW_LINE DEDENT