0

I came across problem I need some help with.

Say I have this following 11 strings (with repeats) $a, b, b, c, c, c, d, d, d, d, d.$

Now the permutation is : $11!/(2! \times 3! \times 5!)$ that is something I know.

But say I pick $4$ out of the $11$ and want to count the distinct ones. Is there a formula for that or do I have to count using different cases.

Thanks in advance.

N. F. Taussig
  • 76,571
  • I posted an answer, but I just wanted to ask for clarification: are you looking for a formula that can easily executed by hand or are you looking for something that would be easy to put into code or into mathematical software of some sort? My answer doesn't really make the problem any easier to do by hand, but it does make it easier to put into mathematical software or to write in code (as four nested for-loops). – benguin Apr 20 '17 at 02:01
  • Thanks for your answer. I had something similar in mind (and that is what I referred to as the cases). Your summation was the cases I had in mind. What I was hoping was some simple/elegant formula exist for problems like these. – user1612986 Apr 20 '17 at 02:04
  • Would a recursive formula/algorithm that works with lists of arbitrary numbers of distinct elements be of any interest? – benguin Apr 20 '17 at 02:07
  • Any answer is always interesting to know. But I was wondering if something elegant exist which I did not think of. I am not trying to program or compute I am trying to develop a better understanding of the problem. – user1612986 Apr 20 '17 at 02:13
  • If you look at some of these questions (https://math.stackexchange.com/questions/229430/how-many-integer-solutions-to-a-linear-combination-with-restrictions https://math.stackexchange.com/questions/146477/how-can-i-determine-the-number-of-unique-hands-of-size-h-for-a-given-deck-of-car/146489#146489 https://math.stackexchange.com/questions/203835/enumerating-number-of-solutions-to-an-equation/203839#203839) then some people provide some solutions using a combination methods called of stars-and-bars and inclusion/exclusion principle. In general, these kind of problems are usually a bit messy. – benguin Apr 20 '17 at 02:18
  • I could state the answer recursively; however, the recursion would be based on my earlier answer involving nested sums so I don't think it would provide much more understanding of the problem. – benguin Apr 20 '17 at 02:32

2 Answers2

1

This can be solved by first considering all possible combinations of four characters, and then discarding invalid combinations. There are $4^4 = 256$ unique strings which can be formed using the characters $a, b, c, d$. However, we must discard:

  • Strings which consist of four $a$'c, four $b$'c and four $c$'s, for a total of 3 permutations;
  • Strings which consist of three $a$'s and three $b$'s. In the former case, there are four ways to select the non-a character, and three characters ($b, c, d$) to select, for a total of $4 \cdot 3 = 12$ permutations. A similar approach can be used in the latter case, again resulting in 12 permutations;
  • Strings which consist of two $a$'s. In this case, there are six ways to select the positions of the non-$a$ characters. Furthermore, there are three combinations of two different characters ($bc, bd, cd$) with two permutations each, and three combinations with two similar characters ($bb, cc, dd$) with one permutation each. As such, there are $6 \cdot (3 \cdot 2 + 3 \cdot 1) = 54$ possible permutations.

Discarding these combinations, we arrive at $256 - 3 - 24 - 54 = 175$ valid strings of 4 characters.

jvdhooft
  • 7,589
  • 9
  • 25
  • 47
0

For any permutation, let $A,B,C,D$ be the number of $a$'s, $b$'s, $c$'s, and $d$'s that are in the permutation respectively. If you want a permutation that consists of picking $4$ of the $11$ elements, then we have that $A+B+C+D = 4$.

Say we construct a permutation by picking the amount of each letter starting at $a$ and ending at $d$. Notice that we can either pick $0$ or $1$ $a$'s. Afterwards, we can pick anywhere from $0$ to $2$ $b$'s. After that, we can pick anywhere from $0$ to $3$ $c$'s as long as we don't go over the limit of picking four elements. In other words, we can pick anywhere from $0$ to $\min(3,4-(A+B))$ $c$'s. Similarly, we can pick anywhere from $0$ to $\min(5, 4-(A+B+C))$ $d$'s.

Thus, we could express the number of permutations as: $$\sum_{A=0}^1\sum_{B=0}^2\sum_{C=0}^{\min(3,4-(A+B))}\sum_{D=0}^{\min(5, 4-(A+B+C))} \frac{4!}{A!B!C!D!}.$$

I will say that this nested sum isn't really pretty by any means, so I'm sure both myself and the OP would like if anyone else can find a more elegant formula :)

benguin
  • 3,846