Weighted random value generator
Given values with positive weights, write a generator that returns a value at random with probability proportional to its weight. Build it once and answer many calls quickly, and explain how you would test that the output follows the weights.
No answer yet. Write the first one; the best answer gets endorsed.
