- a) You are given the word "CALENDAR". How many ways can you rearrange the letters with the restriction that 'C' and 'A' must be together?
- b) With the same word "CALENDAR", how many ways can you rearrange the letters with the restriction that 'C' and 'A' must be together and 'N' and 'D' cannot be together?
- Given the word "POLYNOMIAL", how many ways can you rearrange the letters such that 'P' is next to 'O' and 'N' and 'M' cannot be together.
Normally, for a problem of this nature, I would use Inclusion-Exclusion theory to attack each of the three problems. See
this article for an introduction to Inclusion-Exclusion.
Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula. Inclusion-Exclusion generalizes well, which makes it a very handy tool to have in your toolbox.
Unfortunately, it would take a very sophisticated intuition to deal with Inclusion-Exclusion, for these problems. Therefore, I will use the alternative attack method of a hybrid of Inclusion-Exclusion with the direct approach. This hybrid approach, will be easier for a student new to Combinatorics to understand.
$\underline{\text{Preliminary Result}}$
Lemma-1
Suppose that you have a multiset of $~(n+2)~$ letters, where one of the letters has a multiplicity of $~2,~$ and each of the other $~n~$ letters are distinct (i.e. have a multiplicity of $~1$).
For example, in the multiset $~\{ ~A,A,C,L,N,D,E,R\},~$ the letter A has a multiplicity of $~2,~$ and the other letters in the multiset are distinct.
Then:
The total number of ways of rearranging the letters in the multiset is
$~\dfrac{(n+2)!}{2!}.$
Assuming that the multiset contains two A's, and one C, the total number of ways of rearranging the letters in the multiset so that the C is together with one of the A's is
$~\displaystyle [ ~2 \times (n+1)! ~] - n!.$
Proof
For the first bullet point, let A-1,A-2 represent the multiset element of multiplicity $~2.$ Then, when computing the number of rearrangements of the $~(n+2)~$ elements of the multiset, the computation of $~(n+2)!~$ must be adjusted by the over-counting adjustment factor of $~\dfrac{1}{2!}.~$
This is because otherwise, the rearrangements where A-1 precedes A-2 would be counted as distinct from the rearrangements where A-2 precedes A-1.
For the second bullet point, you can assume that the C and one of the A's have been fused into one unit. So, you now have $~(n+1)~$ distinct units to permute, and the fused unit can be internally permuted in $~(2!)~$ ways.
However, as discussed by the OP (i.e. original poster), this would over-count the rearrangements that have form "...ACA...". If you fuse the A,A, and C elements into an ACA fused unit, you now have $~n!~$ units to permute.
Therefore, the number of over-counted rearrangements that must be deducted, is $~n!.$
Therefore, the computation for the second bullet point is $~\displaystyle [ ~2 \times (n+1)! ~] - n!.$
$\underline{\text{Problem (1a)}}$
Here, you can simply apply the formula from the second bullet point of Lemma-1, with $~n = 6.$
So, the computation is $$[ ~2 \times 7! ~] - 6!$$
$\underline{\text{Problem (1b)}}$
Lemma 1 may be applied to this problem by:
Computing the number of ways that C is together with one of the A's.
Computing the number of ways that C is together with one of the A's, and the N and D are together.
Subtracting the computation in the second bullet point above, from the first bullet point above.
For the first bullet point to problem (1b), the computation has already been done in problem (1a), and is
$$[ ~2 \times 7! ~] - 6!$$
For the second bullet point to problem (1b), re-interpret this bullet point by redefining the original multiset into the multiset $\{ ~\text{A, A, C, L, E, R, X} ~\}, ~$ where the X element symbolizes the fused unit of the N and the D. The only adjustment to this re-interpretation is that the scalar of $~(2!)~$ is needed, since the fused unit of X = ND can be internally permuted in $~2!~$ ways.
Then, the revised multiset has $~(5+2)~$ elements, one of which has multiplicity $~2.$ Therefore, the computation for the second bullet point to problem (1b) is
$$2 \times \left\{ ~ [ ~2 \times (6!) ~] - 5! ~\right\} = (4 \times 6!) - (2 \times 5!).$$
So, the computation for the third bullet point to problem (1b), which represents the answer to problem (1b), is
$$\{ ~[ ~2 \times 7! ~] - 6! ~\} - \left\{ ~(4 \times 6!) - (2 \times 5!) ~\right\} $$
$$= (5!) \times \{ ~[84 - 6] - (24) + 2 \} = 56 \times 5!.$$
$\underline{\text{Problem (2)}}$
The approach taken in Problem (1b) will be repeated. However, first the structure of the two multisets must be compared against each other.
$$\text{\{A,A,C,E,L,R,N,D\}} ~~\text{versus}~~
\text{\{O,O,L,L,P,Y,I,A,M,N\}}.$$
In the expression above, the LHS multiset has $~8~$ elements, where one of the elements has multiplicity $~2.$
In the expression above, the RHS multiset has $~10~$ elements, where two of the elements each have multiplicity $~2.$
The analysis of Lemma-1, and the analysis of the previous section will be adjusted to accommodate the difference in the structure of the two multisets. Similar to the previous problem, problem (2) will be attacked by
Computing the number of ways that P is together with one of the O's.
Computing the number of ways that P is together with one of the O's, and the M and N are together.
Subtracting the computation in the second bullet point above, from the first bullet point above.
For the first bullet point to problem (2), you can reason that the P and one of the O's are fused into the unit X, which may be internally permuted in two ways.
Then, the initial (wrong) computation is $~2 \times ~$ the number of ways of permuting the elements in the multiset
$ ~\text{\{X,O,L,L,Y,I,A,M,N\}}, ~$ which is
$~\displaystyle 2 \times \frac{9!}{2} = 9!.$
Here, rearrangements of form ...OPO... are over-counted, and must be deducted. Letting Z represent the fused unit OPO, you are deducting the number of ways of permuting the elements in the multiset
$ ~\text{\{Z,L,L,Y,I,A,M,N\}}, ~$ which is $~\dfrac{8!}{2!}.~$
Therefore, the computation for the first bullet point of problem (2) is
$$9! - \frac{8!}{2!}.$$
For the second bullet point of problem (2), you can pretend that you are computing the number of ways that the P is next to one of the O's in the multiset $~\text{\{O,O,L,L,P,Y,I,A,W\}},~$ where $~W~$ represents the fused unit $~M,N.~$ The only adjustment to this pretense is that the fused unit W = MN can be internally permuted in $~(2!)~$ ways.
All of the analysis in the first bullet point of problem (2) applies, specifically because the structure of the multiset
$~\text{\{O,O,L,L,P,Y,I,A,M,N\}}~$ is the exact same as the structure of the multiset $~\text{\{O,O,L,L,P,Y,I,A,W\}}.$
That is, both multisets have two distinct elements, each of multiplicity $~2.~$ The only difference between the two multisets is that the second multiset has one less element.
So, for the second bullet point to problem (2), the initial (wrong) computation is
$$8! - \frac{7!}{2!}.$$
The only reason that the above computation is wrong is that the fused unit W=MN can be internally permuted in $~(2!)~$ ways.
Therefore, the correct computation to the second bullet point to problem (2) is
$$2 \times \left[ ~8! - \frac{7!}{2!} ~\right] = (2 \times 8!) - 7!.$$
So, the computation for the third bullet point to problem (2), which represents the answer to problem (2), is
$$\left[ ~9! - \frac{8!}{2!} ~\right] -
\left[ ~(2 \times 8!) - 7! ~\right]$$
$$= 7! \times [ ~(72 - 4) - (16 - 1) ~] = 53 \times 7!.$$