How long does it take you to roll a Yahtzee?
The dice game Yahtzee is a classic. Each player takes turns rolling 5 dice, 3 times each. After each roll, the player can set aside some dice that they want to "keep" and reroll the rest in order to get a better score. The best roll that someone can have is called a "Yahtzee," or 5 dice of the same number, e.g. five 1s, five 2s, etc.
It's easy to determine the probabilities of getting a Yahtzee in 1 roll. You have 5 dice, and a dice has 6 sides, so the chance of getting all 5 the same is ( 6 1 ) 5 , but since there are 6 ways to get a Yahtzee, the probability is really ( 6 1 ) 4 = 1 2 9 6 1 . From this, we can determine that one should expect to roll 5 dice 1296 times before getting a Yahtzee, right?
If you've ever played, you'll realize that the chances of getting a Yahtzee in a game are higher than that. This is because of the rule that you can keep some dice aside after each roll. If after each roll you decide to keep the dice aside that have the number that shows up the most, given an infinite number of rolls (not limited to 3 rolls as in real games), what is the expected number of turns it should take you to get a Yahtzee?
Round your answer to the nearest whole number.
Example sequence of rolls:
Roll 1: 1, 2, 4, 4, 5. Keep the two 4s.
Roll 2: 4, 4, 6, 3, 3. Keep the two 4s.
Roll 3: 4, 4, 1, 1, 1. Keep the three 1s.
Roll 4: 1, 1, 1, 5, 1. Keep the four 1s.
Roll 5: 1, 1, 1, 1, 1. Done after 5 rolls.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Awesome solution, my method is a little more technical and requires a bit more background knowledge. I'm glad someone posted a more elementary method. One quick thing, I think it should actually be the following sum: E j = 1 + i = j ∑ 5 p j i E i
Correct. I'll fix it.
I have a challenge to add to this problem: is the strategy chosen here optimal?
Specifically, if you roll ⟨ a , a , b , b , c , ⟩ , is it efficient to reroll ⟨ b , b , c ⟩ , or would it pay off to leave the a 's and b 's and reroll only c ? The answer it not trivial!
Log in to reply
The real question is: have you already solved it?
Log in to reply
Yes, I have. It is more efficient to leave only two and reroll the other three.
(The technique is the same, except with a sixth state representing the situation 2 + 2 + 1.)
Log in to reply
@Arjen Vreugdenhil – Haha I was literally about to reply to you, yeah it takes about 13.016 rolls on average with the new method, so the old method is better. Whether my method is the best possible, I have no idea, but I'd guess it's close to it.
Here is a comparison between the two strategies: on top, your strategy; on bottom, the strategy of rerolling only one die in the case ⟨ a , a , b , b , c ⟩ . Comparing the numbers in the right column, it is even more efficient to reroll everything than the strategy I proposed...
This problem can be solved through the proper use of transition matrices. We can consider ourselves to be in 1 of 5 states when rolling:
State 1: Keep 0 dice aside
State 2: Keep 2 dice aside
State 3: Keep 3 dice aside
State 4: Keep 4 dice aside
State 5: Keep 5 dice aside (Yahtzee)
These states make what is known as a Markov Chain. This means that the probability to get from the current state to the next state is not affected by how it got to the current state. We start by filling out a matrix that contains our probabilities to get from one state to another.
T = ⎣ ⎢ ⎢ ⎢ ⎢ ⎡ 5 4 5 0 0 0 0 3 6 2 5 9 5 0 0 0 6 4 8 1 2 5 2 7 1 0 3 6 2 5 0 0 1 2 9 6 2 5 7 2 5 1 8 5 6 5 0 1 2 9 6 1 2 1 6 1 3 6 1 6 1 1 ⎦ ⎥ ⎥ ⎥ ⎥ ⎤
Each row represents your current state and each column represents your next possible state. The fractions in each column represent the probability that you will reach that state on your next roll, given that you are in another state. For example, if I was currently holding 2 dice back, the chance that I would be holding 4 dice aside after the next roll would be 7 2 5 , because it is in the 2nd row and the 4th column, or T 2 , 4 .
To find the expected value, we need to find the probability that we have reached the final state after each roll. Since once we reach the last state we’re done, we can remove the last row and column from our matrix because they are trivial and make calculation harder.
T = ⎣ ⎢ ⎢ ⎡ 5 4 5 0 0 0 3 6 2 5 9 5 0 0 6 4 8 1 2 5 2 7 1 0 3 6 2 5 0 1 2 9 6 2 5 7 2 5 1 8 5 6 5 ⎦ ⎥ ⎥ ⎤
Finding the probability that you'll end up in a given state after n rolls is as easy as finding T n , then reading the probabilities that the resultant matrix provides us with. We now can use the expected value formula for transition matrices to find our answer. Where τ = [ 1 0 0 0 ] , I is the Identity Matrix, and 1 is a column vector of all 1s:
E ( Y a h t z e e ) = τ ( I + T + T 2 + T 3 + … ) 1 = τ ( I − T ) − 1 1
E ( Y a h t z e e ) = [ 1 0 0 0 ] ⎣ ⎢ ⎢ ⎡ 5 4 / 4 9 0 0 0 6 7 5 / 3 9 2 9 / 4 0 0 1 5 0 0 / 5 3 9 3 0 / 1 1 3 6 / 1 1 0 9 4 5 7 5 / 1 7 2 4 8 9 6 5 / 1 7 6 6 0 / 1 1 6 ⎦ ⎥ ⎥ ⎤ ⎣ ⎢ ⎢ ⎡ 1 1 1 1 ⎦ ⎥ ⎥ ⎤ ≈ 1 1 . 0 9
This means that following this method should give you a Yahtzee in approximately 1 1 rolls.
Problem Loading...
Note Loading...
Set Loading...
Garrett Clarke gave the standard MarPkov chain / linear algebra solution. Here is a more elementary solution, without the use of linear algebra techniques.
General strategy
Just like Garrett did, we can consider 5 "states", depending on how many dice we are keeping aside. Of course, for the first roll we have state "zero".
We will calculate
It should be clear immediately that p i j = 0 for j < i . Also, E 5 = 0 because if we have Yahtzee there are no more rolls left.
The crucial step in the calculation is the fact that E i = 1 + j ∑ p i j E j : the number of rolls needed is one (the current roll) plus the weighted average of the rolls that will be needed afterward.
Calculation of E 4
To see how this pans out, suppose that we have rolled four of a kind: ⟨ a , a , a , a , b ⟩ , with a = b . We keep the four a 's behind, and re-roll the one die with a different value. Let x be the new value of this die.
There are six possible outcomes, which we classify as follows:
Thus p 4 5 = 6 1 and p 4 4 = 6 5 . The expected number of rolls from state 4 is E 4 = 1 + p 4 4 E 4 + p 4 5 E 5 ; E 4 = 1 + 6 5 E 4 ; remember that E 5 = 0 . Solve this to find 6 1 E 4 = 1 ∴ E 4 = 6 .
Thus from state 4 we expect to need six rolls to get Yahtzee.
Calculation of E 3
If we have rolled ⟨ a , a , a , b , c ⟩ (with b and c possibly equal), we re-roll two dice with outcomes x , y . There are 6 2 = 3 6 possible outcomes in three categories:
The equation for E 3 becomes E 3 = 1 + p 3 3 E 3 + p 3 4 E 4 + p 3 5 E 5 = 1 + 3 6 2 5 E 3 + 1 8 5 E 4 ; substituting E 4 = 6 and solving we get 3 6 1 1 E 3 = 1 + 1 8 5 ⋅ 6 ∴ 1 1 E 3 = 3 6 + 6 0 = 9 6 ∴ E 3 = 1 1 9 6 = 8 1 1 8 .
Calculation of E 2
And so we continue. If we have two a 's and re-roll three dice, there are 3 6 = 2 1 6 possible outcomes in six categories.
We can now write and solve the equation for E 2 : E 2 = 1 + p 2 2 E 2 + p 2 3 E 3 + p 2 4 E 4 + p 2 5 E 5 ; E 2 = 1 + 9 5 E 2 + 2 7 1 0 ⋅ 8 1 1 8 + 7 2 5 ⋅ 6 ; E 2 ≈ 1 0 . 4 6 . In other words, once we have two dice with the same value, we expect to roll 10.46 more times to get Yahtzee.
Calculation E 0
You should get the idea now... it is good practice to categorize the 7776 possible outcomes with 5 dice:
This gives the probabilities p 0 0 = 5 4 5 ; p 0 2 = 3 6 2 5 ; p 0 3 = 6 4 8 1 2 5 ; p 0 4 = 1 2 9 6 2 5 ; and p 0 5 = 1 2 9 6 1 .
Use this to write the equation for E 0 and solve. You find E 0 ≈ 1 1 . 0 9 , which we round off to 1 1 .
What about the matrices?
Garrett's solution uses matrices; essentially the values E i are packaged into a vector e and the probabilities p i j become a matrix P . The four equations E i = 1 + j ∑ p i j E j become the single vector equation e = 1 + P e which is algebraically rearranged as e = ( I − P ) − 1 1 . The question is, of course, how to calculate this... well, you need the same calculations as we used above for solving for E i . The linear algebra approach is elegant and more abstract, but ultimately does not save work.