What’s the probability of getting three consecutive numbers among five dice throws

combinatoricsdiceprobability

The problem is stated as follows:

"Roll a 6-sided die five times. Note the results. The order of appearance is irrelevant.

Will there be three consecutive numbers among the results?

Example: if you roll [2,2,4,1,3] the answer is YES"

I have simulated this problem using Python, and I get an estimated probability of YES of P(YES) $\approx$ 0.4 [NB: Edited from 0.3 in the original post].

This is what I have thought of on the analytical solution so far:

We have a 5-tuple of numbers ranging from 1-6. There are $6^5 = 7776$ ordered outcomes and I want to count the ones that have three consecutive numbers.

Since the order does not matter, we can look at the different unique sets of outcomes, e.g.
[X,X,X,X,Y], [X,X,X,Y,Y], [X,Y,Z,M,N] etc, classify which unique sets have three consecutive numbers and calculate all the permutations of these sets (ways to order them based on the number of unique integers) but I don't know a clever way to calculate all of the different possibilities. Can anyone help me on the way here?

Best Answer

The event that you have three consecutive numbers is the union of five disjoint events:

$$ \overline3456\cup123\overline4\cup234\overline5\cup\overline2345\cup2345\;, $$

where a number with or without a bar indicates that that number is absent or present, respectively. The first four of these have the same probability, so we only need to calculate $2$ different probabilities. By inclusion–exclusion, we have

$$ \mathsf P(\overline3456)=\sum_{j=0}^3\binom3j(-1)^j\left(\frac{5-j}6\right)^5=\frac{125}{1296} $$

and

$$ \mathsf P(2345)=\sum_{j=0}^4\binom4j(-1)^j\left(\frac{6-j}6\right)^5=\frac5{81}\;. $$

Thus the probability to get three consecutive numbers is

$$ 4\cdot\frac{125}{1296}+\frac5{81}=\frac{145}{324}\approx45\%\;. $$

Related Question