# How to find number of strings generated by permuting the given string satisfying the below conditions?

The question goes like this-

How many strings can be generated by permuting the characters of “abbbbcccdeff” such that there are only 3 mismatchings and the rest 9 are same ?

My attempt-

Obviously, If the string was having only distinct characters(like-“abcdefghijkl“) then the answer would have been- 2*(12C9)=440 strings[as there are 12 characters and 9 of them have to be same]. I can calculate this for strings having distinct characters only, but I am failing to generalise this for strings with repeating characters.

I can manually find all pairs,but this method is very time-consuming,like-for the case of- “abbbcc” there comes a total of 12 such strings . These are-
bbbcac,bbbcca,bbcbac,bbcbca,bcbbac,bcbbca,cabbbc,cabbcb,cbabbc,cbabcb,cbbabc,cbbacb

Where I am failing?

I need a quick solution(some kind of generalised formula) instead of counting it manually

#### Solutions Collecting From Web of "How to find number of strings generated by permuting the given string satisfying the below conditions?"

There is $1$ letter with $4$ occurrences, $1$ letter with $3$ occurrences, $1$ letter with $2$ occurrences and $3$ letters with $1$ occurrence. Thus the number of triples of distinct letters is

$$\binom30(4\cdot3\cdot2)+\binom31(4\cdot3\cdot1)+\binom31(4\cdot2\cdot1)+\binom31(3\cdot2\cdot1)+\binom32(4+3+2)\cdot1+\binom33=24+36+24+18+27+1=130\;.$$

Each of these can be permuted in $2$ ways, for a total of $2\cdot130=260$ permutations.