Suppose you want to make a random 9 digit number, using every number from 1 to 9 exactly once. You have a process called random(top) that gives a random number up to top (if top was 5, it would give random numbers from 1 to 5)
a) How could you do this?
b) If top couldn't be more than 9, how could you do this using random(top) only 9 times (or less)?
(In reply to The goal of this problem....
by Brian Smith)
No, Gamer specifically says he wants a random 9-digit number, so 1 through 99,999,999 are not acceptable outputs, and he wants every digit from 1 to 9 to appear exactly once in the output number, also far from random as zeros and repeated digits are disallowed. Only 9! = 362,880 numbers out of a billion satisfy this is about 1 in 2756, so it's highly selective rather than just any random number in the range.
Posted by Charlie
on 2003-05-02 08:27:21