Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Random

Name: Anonymous 2012-02-01 5:14

You are given a function randBit() that returns {0,1}

You want to write a function randNum(start,stop) {a,b} where the function will return a number between a and b with even distribution.


The function is required to run in a guaranteed time, so you can't just use binary representation. ex) you want a number between 0 and 10, the closest bit combination is 16, so a bin representation will fail 6 out 16 times.  What is the best way to do this?

Name: Anonymous 2012-02-02 12:53

>>19
I wonder how many people on /prog/ are too dense to realize what sarcasm is

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List