PROJECT EULER · #0863
Different Dice
Using only a six-sided fair dice and a five-sided fair dice, we would like to emulate an
For example, one way to emulate a 28-sided dice is to follow this procedure:
- Roll both dice, obtaining integers
and . - Combine them using
to obtain an integer . - If
, return the value and stop. - Otherwise (
being 29 or 30), roll both dice again, obtaining integers and . - Compute
to obtain an integer . - If
, return the value and stop. - Otherwise (with
), roll the six-sided dice twice, obtaining integers and . - Compute
to obtain an integer . - If
, return the value and stop. - Otherwise (with
), assign and go back to step 7.
The expected number of dice rolls in following this procedure is 2.142476 (rounded to 6 decimal places). Note that rolling both dice at the same time is still counted as two dice rolls.
There exist other more complex procedures for emulating a 28-sided dice that entail a smaller average number of dice rolls. However, the above procedure has the attractive property that the sequence of dice rolled is predetermined: regardless of the outcome, it follows (D5,D6,D5,D6,D6,D6,D6,...), truncated wherever the process stops. In fact, amongst procedures for
Different values of
Define
Let
Find
Write-up coming later
The complete problem is available here. An approach, code, and answer will be added later.