RosettaCodeData/Task/Seven-sided-dice-from-five-.../00-TASK.txt

16 lines
852 B
Plaintext

;Task:
(Given an equal-probability generator of one of the integers 1 to 5
as <code>dice5</code>), &nbsp; create <code>dice7</code> that generates a pseudo-random integer from
1 to 7 in equal probability using only <code>dice5</code> as a source of random
numbers, &nbsp; and check the distribution for at least one million calls using the function created in &nbsp; [[Verify distribution uniformity/Naive|Simple Random Distribution Checker]].
'''Implementation suggestion:'''
<code>dice7</code> might call <code>dice5</code> twice, re-call if four of the 25
combinations are given, otherwise split the other 21 combinations
into 7 groups of three, and return the group index from the rolls.
<small>(Task adapted from an answer [http://stackoverflow.com/questions/90715/what-are-the-best-programming-puzzles-you-came-across here])</small>
<br><br>