<s>[INST] Combinatorics: premutations with repetition? I have following problem from combinatorics:

Let's have set of 8 distinct items: {a,b,c,d,e,f,g,h}
How many ways we can combine 10 of them if we know:
  
  
*
  
*We start with A and end with H
  
*Every item of the set must be in the result at least once.
  

I started as such ... we know that A and H are already at positions: (A)()()()()()()()()(H)
So we need to find combinations for the rest of the "fields" and there we have:


*

*6 unique items

*2 repeating items


Hence I arrived to this: 8! + 6*P*(3,1,1,1,1,1) + 2*7*P*(2,1,1,1,1,1,1) + 15*P*(2,2,1,1,1,1)
Is it correct or am I doing it wrong ?
 [/INST] Since $a$ must appear in the first of the ten positions, $h$ must appear in the last position, and each of the eight letters in the set $\{a, b, c, d, e, f, g, h\}$ must appear at least once, either one letter appears three times or two letters appear twice each.  
Consider cases:


*

*The letter $a$ appears three times:  Since $a$ appears in the first position and $h$ appears in the last position, we must fill two of the remaining $8$ positions with an $a$, which can be done in $\binom{8}{2}$ ways, then fill the remaining six positions with the remaining letters, which can be done in $6!$ ways.  Hence, the number of arrangements in which $a$ appears three times is 


$$\binom{8}{2} \cdot 6! = \frac{8!}{6!2!} \cdot 6! = \frac{8!}{2!}$$


*The letter $h$ appears three times:  A similar argument shows that this can also occur in $$\frac{8!}{2!}$$ ways.

*A letter other than $a$ or $h$ appears three times:  First, we must select one of the six remaining letters to be repeated.  Next, we select three of the eight remaining positions for the repeated letter, which can be done in $\binom{8}{3}$ ways, then fill the five remaining positions with the remaining letters, which can be done in $5!$ ways.  Thus, the number of arrangements in which a letter other than $a$ or $h$ appears three times is
$$6 \cdot \binom{8}{3} \cdot 5! = 6 \cdot \frac{8!}{5!3!} \cdot 5! = 8!$$


*The letters $a$ and $h$ each appear twice:  Each of the letters must appear once in the eight open positions.  Thus, the number of arrangements in which $a$ and $h$ each appear twice is $$8!$$

*The letter $a$ appears twice and a letter other than $a$ or $h$ appears twice: We fill two of the remaining positions with a letter other than $a$ or $h$, which can be done in $\binom{8}{2}$ ways, leaving us with six places where we can place the $a$.  That leaves us with five positions for the remaining five letters, which can be filled in $5!$ ways.  Hence, the number of arrangements in which $a$ appears twice and a letter other than $a$ or $h$ appears twice is 
$$\binom{8}{2} \cdot 6 \cdot 5! = \frac{8!}{6!2!} \cdot 6! = \frac{8!}{2!}$$


*The letter $h$ appears twice and a letter other than $a$ or $h$ appears twice:  A similar argument shows that this can also occur in $$\frac{8!}{2!}$$ ways.

*Two letters other than $a$ or $h$ each appear twice:  There are six ways to choose the first repeated letter and $\binom{8}{2}$ ways to place these letters in the eight open positions.  There are five ways to choose the second repeated letter and $\binom{6}{2}$ to place these letters in the six remaining open positions.  However, we have counted each possible arrangement of the two pairs of repeated letters twice since filling the second and third positions with a $b$ and then filling the fourth and fifth positions with a $c$ is equivalent to first filling the fourth and fifth positions with a $c$ and then filling the second and third ones with a $b$.  Thus, the number of arrangements of the two pairs of repeated letters is $$6 \cdot 5 \cdot \frac{1}{2} \cdot \binom{8}{2} \cdot \binom{6}{2} = 3 \cdot 5 \cdot \binom{8}{2} \cdot \binom{6}{2}$$  Finally, there are $4!$ ways to place the remaining four letters.  Hence, there are $$3 \cdot 5 \cdot \binom{8}{2} \cdot \binom{6}{2} \cdot 4! = 3 \cdot 5 \cdot \frac{8!}{6!2!} \cdot \frac{6!}{4!2!} \cdot 4! = \frac{8! \cdot 3 \cdot 5}{2!2!}$$ such arrangements.
Since the seven cases are mutually exclusive, there are 
$$4 \cdot \frac{8!}{2!} + 2 \cdot 8! + \frac{8! \cdot 3 \cdot 5}{2!2!}$$ 
possible arrangements.
</s>