2

Exam question: Let $D(d_{1},d_{2},...,d_{k})$ denote the number of derangements of a multiset where there are $d_{i}$ copies of elements of the $i$-th kind, for $i=1,...,k$. This means the arrangements of elements of this multiset in a sequence such that in the first $d_{1}$ positions there is no element of the first kind, in the next $d_{2}$ positions there is no element of the second kind, and so on. For example: $D(1,2)=0, D(2,2)=1, D(1,1,2)=2$. The only derangements of the multiset $\{a,b,c,c\}$ are $\langle c,c,a,b \rangle$ and $\langle c,c,b,a \rangle$.

Find $D(2,2,2,3)$. The WolframAlpha website might be useful for calculations.

Initially, I was thinking about the principle of inclusion and exclusion:

$ \frac{9!}{2! \cdot 2! \cdot 2! \cdot 3!} - 6 \binom{8}{1} \binom{7}{2} \binom{5}{2} - 3 \binom{8}{2} \binom{6}{2} \binom{4}{2} + \left( 3 \cdot 2 \cdot 2 \cdot \binom{6}{1} \cdot \binom{6}{1} \cdot \binom{5}{2} + 3 \binom{7}{2} \binom{5}{2} \right) + \left( 3 \cdot 3 \cdot 2 \cdot \binom{7}{1} \binom{6}{2} \binom{4}{2} + 3 \cdot \binom{7}{1} \binom{6}{2} \binom{4}{2} \right)-... $

Where in the first parenthesis I subtract situations when one of the letters a, b, c is in the wrong position, in the second parenthesis when d is in the wrong position, in the third parenthesis pairs but without the letter d and dividing into situations when the pair consists of two identical letters (both letters a, a are in the wrong positions) or two different ones (e.g., a, b). The fourth is the same as the third but is a case for pairs with the letter d. The problem is that there are still seven cases to consider left, and each subsequent one is worse.

Brute force approach gives me $D(2,2,2,3)= 564$.

I have found similar questions Derangement formula for multisets, Derangements of a multiset with "don't cares"? and I tried using the given formula but it doesn't seem to work: WolframAplha.

How can one count these combinations?

Michał
  • 675
  • 1
  • 12
  • You might be find Rook Polynomials useful. – awkward Aug 18 '23 at 12:27
  • It is unclear to me whether a generalized (reasonably elegant) formula exists. My first try in pursuit of such a formula would be to very carefully organize the brute force steps involved in computing D(2,2,2,3). Here, my first try would be to notice that the $~d_4,~$ which has a multiplicity of $~3,~$ when partitioned into the 3 position-groups (1,2), (3,4), (5,6), can not be partitioned as 3-0-0 (in some order), but instead must be partitioned as either (2-1-0) in some order, or (1-1-1). ...see next comment – user2661923 Aug 18 '23 at 13:43
  • So, I would have to then explore each of the mutually exclusive cases, in the hopes that some underlying pattern emerges that ties these cases into one elegant formula. It is very plausible to me that either no such elegant formula exists, or that such an elegant formula exists but will escape my notice. This suggests that my first try is problematic. Assuming that I abandon my first try, $~\color{red}{\text{what does that leave ?}}$ – user2661923 Aug 18 '23 at 13:46
  • One alternative approach is to construct (for example) $~10~$ different sample problems, of which D(2,2,2,3) is one, and use computer assistance to arrive at a final solution for each problem. Then, you would try to manually explore each problem, trying to explain its underlying arithmetic, and hope that from the 10 explanations, a pattern emerges.... and better you than me. – user2661923 Aug 18 '23 at 13:54
  • @user2661923 did this, but it's not easy to see a pattern. Results:

    -$D(2,2)$ for 'aabb': $1$ -$D(2,2,2)$ for 'aabbcc': $10$ -$D(2,2,2,2)$ for 'aabbccdd': $297$ -$D(2,2,2,3)$ for 'aabbccddd': $564$ -$D(1,1,1,1)$ for 'abcd': $9$ -$D(3,3,3,3)$ for 'aaabbbcccddd': $13833$ -$D(2,2,2,2,2,2)$ for 'aabbccddee': $13756$

    – Michał Aug 18 '23 at 16:51