# How many distinct n-letter “words” can be formed from a set of k letters where some of the letters are repeated?

How many distinct n-letter "words" can be formed from a set of k letters where some of the letters are repeated?

Examples:

__

How many 6-letter words can be formed from the letters: ABBCCC?

This is elementary. There are 6! arrangements counting repeats. Then we just divide by 2!3! to account for the repeats caused by the 2!3! identical arrangements of the Bs and Cs

How many 5-letter words can be formed from the letters: ABBCCC?

Excluding A we have $\frac{5!}{2!3!}$

Excluding either B $\frac{5!}{3!}$

Excluding any of the Cs $\frac{5!}{2!2!}$

Then take the sum.

How many 4-letter words can be formed from the letters: ABBCCC?

At this point I find it difficult to procede without far too many cases.

Is there a general approach?

-
Interesting question, perhaps difficult to give a nice answer to. In the particular instance, we remove AB or AC or BB or CC or BC, so the number of cases is manageable. – André Nicolas Nov 16 '12 at 22:11

2
– Jair Taylor Nov 17 '12 at 20:35
Thank you Jair! – a little don Nov 29 '12 at 23:42

## 2 Answers

Let's say you want the word of letters to be $M$-long, with $N$ choices for letters in each space on the word. Then draw something like this:

to enumerate all possible words. In the picture $M=3$ and $N=2$. Let's say you have a deficit in $A$s of magnitude $D_A$ from being able to make a full, $M$-long word of $A$s.

First, assuming none of the deficits overlap (that is, there are no words that violate 2 or more restrictions in the number of letters), find the number of nodes that are less than or equal to $M-D_A$ away from $(A,A,...A)$. This turns out to be $\sum_{k=0}^{k=M-D_A}\binom{M}{k}{(N-1)}^{M-k}$.

For the proof of this, think of a 3-letter word with choices of letter $A$, $B$ or $C$. There are $\binom{3}{0}2^0$ ways of making words with 3 $A$s, $\binom{3}{1}2^1$ ways of making a word with 2 $A$s, etc.

So evidently you need to subtract each sum taking into account the restrictions of each letter from the total number of unrestricted words.

However, it's much more complicated when the sum of two deficits is more than $M$ so that because of the overlap the subtraction will have been too great. Basically the $(N-1)$ in the sum will be some lower number for higher values of $k$ when other letter's restrictions are overstepped, but I can't see a nice formula for it for a given $D_B, D_C...$.

-

It is solved here. In general, you have to account for the duplicates as detailed in the link.

$\frac{_nP_r}{n_1!n_2!...n_k!}$.

where the denominator denotes factorial for indistinguishable or repeated letters.

-

1
Thanks, but, everything at that link is equivalent to my first example only. That formula will not work when n < k. – a little don Nov 16 '12 at 22:02
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 26, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": false}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9386323690414429, "perplexity_flag": "middle"}