1

For given length $n$, calculate number of words consisting of letters $\{A,B,C,D\}$, where $\#A=\#B$ and $\#C=\#D$.

I know that for odd $n$ the answer is $0$. Otherwhise, I think that the result is equal to $\sum_{j=0}^{\frac{n}{2}} \binom{n}{j} \binom{n-j}{j} \binom{n-2j}{n/2 -j}$ (we choose positions for $A$, then for $B$, then for $C$, and the remaining positions for $D$), but I am curious whether we can calculate the result in more simple way.

Gary
  • 31,845

2 Answers2

4

Let $n=2k$

Imagine this as a 2-dimensional random walk. Call "B" the positive $x$ direction, call "D" the positive $y$ direction, meanwhile call $A$ the negative $x$ and $C$ the negative $y$ directions respectively. Now... ignoring the exact letters, you know that exactly half of the positions will be in some sort of "positive direction" whether that was positive $x$ or positive $y$. There are $\binom{2k}{k}$ ways to make such choices.

Now, rotate the image 90 degrees. We observe the same thing, exactly half must be pointed in a (currently) positive direction. Choosing half to do so will then uniquely determine what exact random walk, and as such what string of letters, it was that we are dealing with. Reversing the process is also possible allowing you to prove that this is a bijection. The final answer then:

$$\binom{2k}{k}^2$$

JMoravitz
  • 79,518
  • If I take #$A =, $#$B =2,$ #$C=, $#$D = 3, \dfrac{10!}{(2!)^2(3!)^2} = 25,200$, whereas $\dbinom{10}{5}^2 =63504$ – true blue anil Jun 23 '22 at 13:31
  • @trueblueanil why would you do that? What about also adding in the cases of #A=#B=1 and #C=#D=4, or #A=#B=0 and #C=#D=5 or the reverses as well. Add together all cases and you will see that it does in fact add up to as I say – JMoravitz Jun 23 '22 at 13:35
  • 1
    $2\cdot \left(\binom{10}{0,0,5,5}+\binom{10}{1,1,4,4}+\binom{10}{2,2,3,3}\right) = \color{red}{25200} + 25200 + 6300 + 6300 + 252 + 252 = 63504$. In your comment, you only managed to refer to the red number but missed all others in the sum. Perhaps you misread the question and did not understand that we have not specified the number of $A$'s yet. – JMoravitz Jun 23 '22 at 13:37
  • Oh, I misinterpreted the question meant the number of words with a particular number of $A′s=B′s,$ and $C′s=D's$. Ingenious answer ! – true blue anil Jun 23 '22 at 13:54
  • You mean random walks that start and end in the same position? – Jair Taylor Jun 23 '22 at 14:03
  • @JairTaylor That was clear already, wasn't it? – JMoravitz Jun 23 '22 at 14:04
  • I guess it is. I missed the words "this as" from "Imagine this as a random walk..." where "this" means that the condition is already assumed to be satisfied. – Jair Taylor Jun 23 '22 at 14:09
0

If $\#A=\#B\in [0,n/2] $ is given, then $\#C=\#D = (n-2\#A)/2 = n/2-\#A$. The number $w_n(\#A)$ of words of length $n$ with respective number of $A$'s is thus:

$$\begin{align} w_n(\#A) &:= \frac{(\#A+\#B+\#C+\#D)!}{\#A!\cdot\#B!\cdot\#C!\cdot\#D!} \\ &= \frac{n!}{\#A!^2(n/2-\#A)!^2} \end{align}$$

Summing over all possible $a=\#A$:

$$\begin{align} W_n &:= \sum_{a=0}^{n/2} w_n(a) \\ &= \sum_{a=0}^{n/2} \frac{n!}{a!^2(n/2-a)!^2} \end{align}$$

$$\begin{align} W_{2n} &= \sum_{k=0}^n \frac{(2n)!}{k!^2(n-k)!^2} \\ &= \sum_{k=0}^n \frac{(2n)!}{n!^2} \binom{n}{k}^{\!2}\\ &= \binom{2n}{n}\sum_{k=0}^n \binom{n}{k}^{\!2} = \binom{2n}{n}^{\!2}\\ \end{align}$$

For the last step and

$$\sum_{k=0}^n \binom{n}{k}^{\!2} = \binom{2n}{n}$$

see this question for example.

emacs drives me nuts
  • 10,390
  • 2
  • 12
  • 31