Imagine you are trapped in a post-apocalyptic world and only have a single d20 at your disposal, nothing else whatsoever. What is the ideal way of emulating all other common dice types (d4, d6, d8, d10, d12, d%) using just this d20 and arbitrarily complicated math?

I realize there’s an easy way to make due with a single d6 (using the same d6 also for a coin-like mechanic), but I was wondering if this also works with a d20, and what the criteria are for this to work with a dN, if there is any research on the matter.

Let me preface this by defining a few pointers:

"*ideal*" = as few d20 rolls as possible.

"*emulating*" means mapping output from one or more d20 rolls to whichever die you want to emulate, while maintaining statistical accuracy – each possible output for the desired die must be equally likely.

"*to map*" a number *X* to an interval [1; B] means to apply an operation of the following form:

dB = *X* – B * **int**[(*X* – 1) / B]

where the **int**[] operation demands rounding down (truncation, since the argument will never be negative for the given problem).

Here’s what I have so far, in order of complexity:

Single roll *X*: **d10** = [*X*] if [*X* <= 10], else: [*X* – 10]

Single roll *X*: **d%** is equivalent to d10.

Single roll *X*: **d4** = *X* – 4 * **int**[(*X* – 1) / 4]

Two rolls *X*, *Y*: **d8** = [*X*] if [*X* <= 8], or [*X* – 8] if [9 <= *X* <= 16]. Alternatively, for [*X* > 16], **d8** = [*Y*] if [*Y* <= 8], or [*Y* – 8] if [9 <= *Y* <= 16]. Alternatively, if both [*X* > 16] and [*Y* > 16], **d8** = [*X* – 16] if [*X*+*Y*] = even, else: [*X* – 12].

Three+ rolls *X*, *Y*, *Z*: **d6** = *X* – 6 * **int**[(*X* – 1) / 6] if [*X* <= 18]. If not, check the same for *Y*. If not, check the same for *Z*. If {*X*, *Y*, *Z*} in {19, 20} (which has a 1/1000 chance of happening), map the combination to [1;6]. However, I don’t think it is possible to reliable get this mapping even when adding more and more dice rolls. Of course, it will get vastly unlikely rather quickly, but there does not seem to be a reliable way of using binary values to map to 6 reliably, seeing as it is a product of two primes. What is the lowest number of dice rolls required to achieve a 100% successful outcome, if it is possible at all?

The same issue applies to the **d12**, which can be constructed trivially from a **d6** by rolling a **d20** like a coin toss, then either using the initial **d6** value or **d6**+6. This might not, however, be the ideal solution for this.

I would greatly appreciate any insight into the matter, as this has kept my mind busy for quite some time now. I’m pretty sure it cannot be reliably done for the **d6** and **d12**, but I would appreciate any kind of closure or proof you peoples might be able to provide!