All problems
Multinomial Count
Problem
Count the distinct orderings of a multiset described by its item counts.
The multinomial count is n! / (c_1! * c_2! * ...) where n = sum(counts). Return 0 if any count is negative and 1 for an empty list.
Hint
Divide n! by the factorial of each repeated count.
Test cases
case 1
in: [[2,1]]
expected: 3
case 2
in: [[1,1,1]]
expected: 6
case 3
in: [[3,0]]
expected: 1
case 4
in: [[2,2,2]]
expected: 90
case 5
in: [[]]
expected: 1
Starter codePython
import math
def multinomial_count(counts):
# Your code here
pass5 test cases · run your code against them in the editor