# How many 5 letter different words can be formed using the letters AAASSSBB [closed]

I saw that these sort of questions have been asked before, but not exactly this kind of problem: creating 5 DIFFERENT words, not just all possible combinations.

The words don't need to have any meanings.

I'd appreciate an explanation in addition to the solution.

• If you tried anything you should show your work. Commented Aug 11, 2017 at 14:37
• Related
• grep -E '^[asb]{5}$' /usr/share/dict/words – Mark Commented Aug 11, 2017 at 23:35 ## 5 Answers $$\begin{array}{c|c|c} \text{Letters} & \text{Calculation} & \text{# Possibilities}\\ \hline\\ AAASS & \displaystyle\binom{5}{3} & 10 \\\\ AAASB & \displaystyle\binom{5}{3} \cdot 2 & 20\\\\ AAABB & \displaystyle\binom{5}{3} & 10\\\\ AASSS & \displaystyle\binom{5}{2} & 10\\\\ AASSB & \displaystyle\binom{5}{2} \cdot \binom{3}{2} & 30\\\\ AASBB & \displaystyle\binom{5}{2} \cdot 3 & 30\\\\ ASSSB & 5\cdot \displaystyle\binom{4}{3} & 20\\\\ ASSBB & 5\cdot \displaystyle\binom{4}{2} & 30\\\\ SSSBB & \displaystyle\binom{5}{3} & 10\\\\ \end{array}$$ This gives a total of $$\boxed{170}$$ One way is to use generating functions. Find the coefficient of$x^5$in: $$f(x) = 5! \cdot (1 + x + x^2/2! + x^3/3!)^2 \cdot (1+x + x^2/2!)$$ In general, the number of length-$n$words that can be achieved from an alphabet of$k$distinct letters containing$b_i$counts of letter$i$(over all$1 \leq i \leq k$), is found by taking the coefficient of$x^n$of$f(x)$where: $$f(x) = n!\prod_{i=1}^{k}\left(\sum_{j=0}^{b_i}\frac{x^j}{j!}\right)$$ One nice thing about this approach (in my opinion) is that it is generalizable and easily adjustable, and doesn't require individual case-counting. • How did you derive this formula and why is coefficient of$x^5$result? Commented Aug 11, 2017 at 14:49 • @johnnobody Coefficient of$x^5$because you are choosing$5$letters. Commented Aug 11, 2017 at 14:51 • OK, so if would have 4 letter words it would be at$x^4$? But how do you calculate this function? Commented Aug 11, 2017 at 14:55 • Yes, it would be$4!$instead of$5!$and you'd be looking at the coefficient of$x^4$instead of$x^5$. There are$n!$ways to arrange the$n$letters that are selected, but if we pick$j$letters of any particular type ($A$,$S$, or$B$), we must divide by$j!$to render them indistinguishable amongst themselves. Generating functions in general are useful for counting up the number of ways to arrive at a particular outcome. Commented Aug 11, 2017 at 15:02 • Answered a similar question a long while back using this same approach, another example can be seen here: math.stackexchange.com/a/1890120/97648 Commented Aug 11, 2017 at 15:12 There are words that use only two different letters, and there are words that use all three.$2$letters: It must be three of one and two of another.$3A$'s,$2S$'s$3A$'s,$2B$'s$3S$'s,$2A$'s$3S$'s,$2B$'s In any case, the number of words is$\binom53=\frac{5!}{3!2!}=\frac{5\cdot4}{2\cdot1}=10$With four choices of letter-pairs, that gives us$40$words.$3$letters: The possible formats here are$3$of one letter, and$1$each of the other two, or$1$of one letter, and$2$each of the other two.$3,1,1$: The letter occurring$3$times could be$A$or$S$, so there are two lists of letters to work with. In either case, you can form$20$words. That's$\binom53=10$choices for where the three copies of one letter go, and$2$ways to fill the remaining blanks. That's another$40$words.$2,2,1$: Now any of the three letters can be the one that occurs once. Given a letter-list, We have$5$ways to choose where the lone letter goes, and$\binom42=6$ways to place the remaining ones. We have$3\cdot 5\cdot 6=90$Finally,$40+40+90=170$• OK good, we meet having approached from opposite ends. :-) Commented Aug 11, 2017 at 14:53 • I also got the same answer. Definitely$170$:) Commented Aug 11, 2017 at 15:11 • thank you i finally understand it :) Commented Aug 12, 2017 at 19:51 If we were just forming length-$5$words that consisted of the three letters$A,S,B$, there would be$3^5$options - each letter position has$3$independent choices. We need to restrict that total to reflect the restrictions on count of each letter. In this case you cannot have a word that breaks constraint on$2$letters at the same time. How many of those unconstrained words have$4$or$5$copies of$A$? Clearly the answer is$1+2\binom 5 4 = 11$:$AAAAABAAAASAAAAABAAA$etc. and similarly for$S$. Then for$B$-constraint-breaking words, there are those$11$plus$\binom 5 3(2+2) = 40$. So we end with$3^5-73=170$valid options. • If it were possible to have multiple constraints simultaneously broken, this could be extended using an inclusion-exclusion approach. Commented Aug 11, 2017 at 14:55 • I agree that the number of words with$4$or$5$As is $$2\binom{5}{4} + \binom{5}{5} = 2 \cdot 5 + 1 = 10 + 1 = 11$$ and that there are the same number of words with$4$or$5$Ss. However, the number of words with$3$,$4$, or$5$s is $$2^2\binom{5}{3} + 2\binom{5}{4} + \binom{5}{5} = 4 \cdot 10 + 2 \cdot 5 + 1 = 40 + 10 + 1 = 51$$ which yields a total of$11 + 11 + 51 = 73$prohibited words. Commented Aug 12, 2017 at 9:58 • Sure, that's what I got too in my answer... I did consider switching the$(2+2)$to$2^2$later on. Perhaps you missed that I acknowledge the$11$options for$4$or$5B$s and only calculated the$3B\$s options explicitly. Commented Aug 12, 2017 at 13:32
$${5!\over 3!2!0!}+ {5!\over 3!1!1!}+{5!\over 3!0!2!}+{5!\over 2!3!0!}+{5!\over 2!2!1!}+{5!\over 2!1!2!}+{5!\over 1!3!1!}+{5!\over 1!2!2!}+{5!\over 0!3!2!} =$$
$$=4{5!\over 3!2!}+ 2{5!\over 3!}+3{5!\over 2!2!} = 170$$