What is the optimal number of dice to roll a Yahtzee in one roll?

Description

In the game of Yahtzee, 5 dice are rolled to determine a score. One of the resulting rolls is called a Yahtzee.

To roll a Yahtzee you must have 5 of a kind. (5 1's or 5 2's or 5 3's etc..).

In the game of Yahtzee you can only have 5 dice. However, for the purpose of this question I want to entertain adding more dice to the equation. Therefore I'd like to define a Yahtzee as follows:

To roll a Yahtzee you must have exactly 5 of a kind, no more or no less. (5 1's or 5 2's or 5 3's etc..).

Examples

Let's look at some rolls with 6 dice

The following would be a Yahtzee:

1 1 1 1 1 4

6 3 3 3 3 3

5 5 3 5 5 5

The following would not be a Yahtzee:

1 1 1 3 3 3

1 1 1 1 5 3

1 1 1 1 1 1

- Note that the last roll does technically contain 5 1's, however because the roll as an entirety contains 6 1's this is not a Yahtzee.


Let's look at some rolls with 12 dice

The following would be a Yahtzee:

1 1 2 1 2 1 4 4 1 3 6 2

1 1 1 1 1 2 2 2 2 2 3 3

1 1 1 1 1 2 2 2 2 2 2 2

- Note that the first roll is a Yahtzee with 5 1's, this roll is to illustrate that order doesn't matter.

- Note that the second roll has 2 Yahtzees, this is a roll that counts as a Yahtzee

- Note that the third roll has a Yahtzee with 1's but has 7 2's. This roll is a Yahtzee because it contains exactly 5 1's. The 7 2's do not nullify this roll.

The following would not be a Yahtzee:

1 1 1 2 2 2 3 3 3 4 4 4

1 1 1 1 1 1 6 6 6 6 6 6

- Note that the last roll has 6 1's and 6 6's. Because exactly 5 of one number (no more, no less) is not present, this roll does not contain a Yahtzee.

The Question

What is the optimal number of dice to roll a Yahtzee in one roll?

A more generalized form of the question is as follows: Given $n$ dice, what is the probability of rolling a Yahtzee of length $y$ in one roll.


Solution 1:

By inclusion-exclusion, the full probability of Yahtzee is: $$\frac{1}{6^n}\sum_{k=1}^{\min(6,n/5)} (-1)^{k+1} \binom{6}{k} (6-k)^{n-5k} \prod_{j=0}^{k-1} \binom{n-5j}{5}.$$ If you prefer, write the product with a multinomial: $$\prod_{j=0}^{k-1} \binom{n-5j}{5}=\binom{n}{5k}\binom{5k}{5,\dots,5}.$$ Looks like $n=29$ is the uniquely optimal number of dice: \begin{matrix} n &p\\ \hline 28 &0.71591452705020 \\ 29 &0.71810623718825 \\ 30 &0.71770441391497 \\ \end{matrix} enter image description here

Here is the SAS code I used:

proc optmodel;
   set NSET = 1..100;
   num p {n in NSET} = 
      (1/6^n) * sum {k in 1..min(6,n/5)} (-1)^(k+1) 
      * comb(6,k) * (if k = 6 and n = 5*k then 1 else (6-k)^(n-5*k)) 
      * prod {j in 0..k-1} comb(n-5*j,5);
   print p best20.;
   create data outdata from [n] p;
quit;

proc sgplot data=outdata;
   scatter x=n y=p;
   refline 29 / axis=x;
   xaxis values=(0 20 29 40 60 80 100);
run;

Solution 2:

As an alternative approach, we can use the symbolic method to deduce that the generating function for the class of all rolls not containing a Yahtzee is given by

$$ f(z) = (e^z - z^5/5!)^6 $$

while the generating function for all rolls is

$$ g(z) = (e^z)^6. $$

The probability that a roll of $n$ dice yields a Yahtzee is given by

$$ 1-[z^n]f(z)/[z^n]g(z). $$

Using Mathematica:

f[z_] := (Exp[z] - z^5/5!)^6;
g[z_] := Exp[z]^6;
ans[n_] := 
  1 - SeriesCoefficient[f[z], {z, 0, n}]/
    SeriesCoefficient[g[z], {z, 0, n}];
DiscretePlot[ans[n], {n, 10, 40}]

enter image description here