[thelist] Need 4 random numbers - how??

Anthony Baratta Anthony at Baratta.com
Sat Apr 8 01:52:09 2000


CDitty wrote:
> 
> Hello all, hope I'm not the only one up this late coding.  I need a way to
> generate 4 random numbers to of a total that is retrieved from a DB.  This
> I can do with minimal effort.  The part I can't figure out, is how can I
> make sure that none of the 4 numbers are the same?

What I do.....

Calculate first number, store in array. Calculate second number, check against first.
Recalc until different. Calculate third check against first and second - recalc until
different. Calculate fourth check against first, second and third - recalc until
different. 

The best way to iterate over the list is to stuff the good results into an array and
foreach over them.

Brute force? Yes. But effective.

-- 
Anthony Baratta
President
KeyBoard Jockeys
                    South Park Speaks Version 3 is here!!!
                       http://www.baratta.com/southpark
                              Powered by Tsunami