Rearranging a string such that specified characters appear in order The letters in the word GUMTREE and KOALA are rearranged to form a 12-letter word where KOALA appears precisely in order but not necessarily together. How many ways can this happen?
So I attmepted it via this method:
Firstly arrange like this since KOALA must be in order but not necessarily together: (let the fullstops (.) be spots for the letters in GUMTREE. There are $7$ letters in GUMTREE and $6$ full stops so $6^7$.
.K.O.A.L.A.
Butthere are two E's so $\frac{6^7}{2!}$. The letters in KOALA are fixed so they have $1$ way each, except for A (there are two so the first A has two choices and the second A has one choice)
Therefore, $$2\cdot\frac{6^7}{2!}=279936$$
But the answer is 1995840 arrangements
I belive my method is very close but I am forgetting to multiply by something. Can someone point out my logical flaw? Otherwise the worked solutions propose $\frac{12!}{5!2!}$, but I don't get why you divide by 5! for the KOALA, since they are not identical letters... regardless it would be great to understand both ways!
Thanks
 A: You are assuming that the letters for the two words are interleaved, when they do not need to be.  For example, "KOALAGUMTREE" is a permissible arrangement, as is "GUMTREEKOALA" or "GUMKOALATREE."  The problem only stipulates that the letters in "KOALA" appear in sequence.
So, count the number of ways to order the letters in "GUMTREE."  There are $7$ letters, two of which are identical; therefore, there are $7!/2!$ such arrangements of the letters.  For "KOALA," there is only one permissible arrangement.  So now all that is left is to figure out how many combined arrangements exist; to do this, note there are a total of $7 + 5 = 12$ letters in total, hence there are $\binom{12}{5}$ ways to select the positions of the letters in "KOALA" among the $12$ total letters.
Hence the correct number of arrangements is $$\frac{7!}{2} \binom{12}{5} = 1995840,$$ as claimed.
A: Probably simplest to frame the problem as arranging 12 letters, in which 2 are identical of one kind (EE in GUMTREE), and 5 are identical of another kind (XXXXX substituting for KOALA, which is treated as a black box since its letters have already been pre-arranged). So, $$\frac{12!}{2!5!},$$ as suggested.
A: This might appeal to you as a simple way
First arrange $-K-O-A-L-A-$ with gaps between letters.
All we need to do is to  count how many ways GUMTREE can be interleaved.
$G$ can be inserted in $6$ ways, but then $U$ can now be inserted in $7$ ways,$M$ can be inserted in $8$ ways, and so on, and finally divide by $2!$ for the repeated $E$
Thus, $\dfrac{6\cdot 7\cdot 8\cdot 9\cdot {10}\cdot{11}\cdot{12}}{2!} = 1995840$
A: Here is the problem with your method of counting -
You are giving each letter of GUMTREE a choice of being in any of the $6$ places. So far so good.
But $6^7$ does not include permutations of "GUMTREE". For example, in the arrangements of all letters of GUMTREE being in the last place as KOALA {GUMTREE}, where are you considering permutations of GUMTREE?
So you may say we can multiply by $\frac{7!}{2!}$ but that brings in a different problem then. You overcount and to use P.I.E or to find multiplication factor for each type of arrangement separately is going to be a lot more work. Why does it overcount? Take an example,
K (G) O (UM) A (TR) L (EE) A
Now if you multiply as we mentioned above, it will also count cases,
K (U) O (GM) A (TR) L (EE) A but those have already been counted in $6^7$.
So it is easier to consider KOALA as letters that are same in total $12$ letters so we have $2$ $E$ and $5$ $X$ giving an answer of $\frac{12!}{5! \, 2!}$.
A: As you said, we have to fill $6$ gaps in $\text{_K_O_A_L_A_}$ with $7$ letters, so if $a$ letters go in the first gap, $b$ letters go in the second gap and so on and $f$ letters go in the sixth gap, we have the equation $a+b+c+d+e+f=7$ whose solution by stars and bars is given by $\displaystyle \binom{7+6-1}{6-1}=\binom{12}{5}$. The number of ways of arranging those $7$ letters as shown by other answers is $\dfrac{7!}{2!}$. Hence, the number of total combinations is $\displaystyle \dfrac{7!}{2!}\binom{12}{5}$.
A: As I understand it, you are doing $7$ trials, one for each letter of GUMTREE. In the first trial, you decide which of the six slots, indicated by full stops, to use for G, in the second you decide which to use for U, and so on.
Here's the problem with that approach: let's say all seven letters of GUMTREE get put in the first slot. You still haven't said how the letters in that slot are to be ordered. There are $7!/2!$ orders, so you might think to multiply by that factor. But let's say that G got put in the first slot, U in the second, and so on up to R in the fifth slot, with both Es put in the sixth slot. Now there is no rearrangement possible, so the appropriate multiplicative factor is $1$, not $7!/2$.
Because of this issue I don't see any simple fix for your approach.
