开发者

simulate dice with fair coin flip [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

Improve this question

Given a fair coin (0/1), how do you simulate fair dice(0 to 5) Obvious answer I know is toss 3 times, treat each toss as a bit to produce (2^3 = 0 to 7) If result == 7, discard and repeat.

Well, theoretically worst case big-O of this is really bad (another question in itself, something to do with monte-carlo algos).开发者_JAVA百科 Lets keep this soln on shelf.

So now my question is, Is there/can there be n number of coin toss that can guarantee simulation of dice ? Of course if exists would like to know minimum number of tosses. :)

In absence of a number that is both divisible by three and 2^n, I couldnt think of any way to solve this. :(

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜