1

Let $X = \{1, 2, 3\}$, and let $S = \{(a,b,c,d): a,b,c,d \in X, \text{and each element in X appears at least once in a,b,c, or d}\}$. How can I find $|S|$?

In other words, if I have a set $X$, and a set $S$ of 4-ary sequences over $X$, and in each sequence all elements in $X$ appears at least once, how do I count the sequences in $S$? How can I count similar sequences of different lengths?

  • The question that I marked this a duplicate of deals with probabilities. However, the same principles apply here -- counting the number of admissible strings is tantamount to calculating the probability of choosing an admissible string if all strings are equiprobable. – joriki Jul 09 '18 at 17:58
  • @joriki Certainly if I could derive the probability of a string being admissible, I could multiply that by the total number of possible strings to get the number of admissible strings. However, I don't quite understand the principles being applied in your linked answer, or how to apply them to my own problem. – Gustav Bertram Jul 10 '18 at 16:47
  • Usually the thing to do in that case would be to ask a new question (as the duplication notice suggests) in which you ask specifically about the parts of existing answers that you don't understand (rather than having the question get answered all over again from scratch). However, since this is a problem that comes up in many contexts and the answers in that other question don't answer it in a generalized form, I've reopened this question and will be posting a more general answer later today (which can then hopefully be used to deal with future duplicates). – joriki Jul 10 '18 at 17:26
  • 1

3 Answers3

2

The existing answers have already shown how to solve your specific example with small numbers. The solution for the general case is a paradigmatic application of the inclusion–exclusion principle.

Let $n$ denote the size of the alphabet ($n=3$ in your case). We want to count the strings of length $k$ that use all $n$ letters. The number of strings that use at most $j$ particular letters is $j^k$. Then by inclusion–exclusion the number of strings that use exactly $n$ particular letters is

$$ \sum_{j=0}^n(-1)^j\binom n{n-j}(n-j)^k=\sum_{j=0}^n(-1)^{n-j}\binom njj^k\;. $$

In your case, with $n=3$ and $k=4$, we get

$$ \sum_{j=0}^3(-1)^{3-j}\binom3jj^4=3^4-3\cdot2^4+3\cdot1^4-0^4=36\;. $$

joriki
  • 242,601
0

If one element appears twice and the other two once we have ${4!\over 2!1!1!}$ arrangements. Now you can choose on 3 ways this element which appears twice, so

$$ |S| = 3\cdot {4!\over 2!1!1!} = 36$$

nonuser
  • 91,557
0

Hint: So, $a$, $b$, $c$, and $d$ must be a permutation of $1$, $2$, $3$, and one repeated element $x\in X$. In how many ways can we choose $x$? In how many ways can we permute $4$ objects consisting three distinct types of objects, with one type occurring twice and each of the remaining two types occurring once?

Batominovski
  • 50,341
  • I have tried $P^3_3$ to permute 1,2,3 for abc, and then four places for x (xabc, axbc, abxc, abcx), then multiply it by the possible values for x (3), but that yields $3!\cdot 4\cdot 3=72$ which is clearly wrong. Trying it the other way you suggested, $P^4_4$ to permute a,b,c,x and then multiplying by 3 for the values of x gives $4!\cdot 4=72$ which is still wrong. I'm double counting, and I'm not sure how to avoid that. – Gustav Bertram Jul 10 '18 at 16:34