I am looking for what the probability of a certain roll for the game of threes. The rules for the game:
Start with five dice, roll all of them, and you must take away at least one die from the pile; that is your score. If you roll a three it counts as a zero in the summation of the total score and the lowest score wins. After you roll the original five dice and have removed at least one, you can choose to reroll the rest, and this process continues until the last die.
For example, rolling the following: 2, 3, 3, 1, 4 is a score of 7 as threes are counts as zeros. Also if I roll 3, 6, 6, 6, 6, I can keep the 3 and reroll the four 6 results in an attempt to get a lower score. In this example the next roll could have 4, 1, 2, 2 and I would have to take at least one away so I would take the 1, for a score of zero(3) + 1, and then reroll the remaining three dice.
SO I could luck out and with rerolls ("with replacement" I guess) and get a score of zero. And preferably I would want to get the lowest possible score.
How would find the probability of rolling a particular score, and what would the maths look like to to find how many threes I could have rolled in a round. For example how would I find the probability of something like rolling: one 3 in the first round (3,x,x,x,x) and then two threes in the second round (3,3,x,x) and then a two in the third round (2,x) and a one the last roll (4), thus ending the game with a score of 6. (obviously x does knot equal 3).
Similar question. We'll assume you want to minimize the mean total.
Rolling strategy
At each stage, you would never set aside a higher die over a lower die. Therefore we can iterate over the dice from lowest to highest; the cost of setting aside $k$ dice is concave up. However, as we shall see, the cost of the remaining dice is concave down, so we do have to consider all $n$ possibilities. Fortunately, with only five dice at most this is not difficult for a computer.
Inductive solution
From here, we can compute the solution using linear memoization.
Example script
Here's a script using my Icepool Python package. You can run it in your browser using this JupyterLite notebook.
Result
5 dice:
Mean cost: 6.254
Die with denominator 470184984576