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: kodak_gallery_programmer !!qmiXqQhekkGXVVD 2012-02-02 8:45

I wonder how many people in /prog don't understand what is being discussed in this thread.

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