At 07:42 PM 2/18/98 +1100, David Duffy wrote: >But I can't >see a way to generate the list of all 20 numbers in random order. The only >thing that springs to mind is generating lots of random numbers and throwing >away any that are out of desired range or are duplicates. Maybe I'm missing >an obvious solution but it has been a long day ! The way that I have always generated lists of random, non-repeating numbers (like shuffling a deck of cards) is to start off with an array of all of the numbers in order. I generate a bunch of random numbers in the same range, and use those random numbers in pairs as the array indices of numbers to swap. For instance, start off with the array a=[1 2 3 4 5 6] Assuming indices run from 1 to 6, a(1)=1, a(2)=2, ... a(6)=6 Pick two random numbers, let's say 3 & 5.... swap a(3) with a(5). Now, the array is [1 2 5 4 3 6]. Pick two random numbers, let's say 2 & 5.... swap a(2) with a(5). Now, the array is [1 3 5 4 2 6]. Keep picking pairs of positions to swap for at least 2n times, where n is the number of positions. To scale random numbers to a desired range, just divide by the size of the range and take the remainder. If your range is an even power of two, just mask off the appropriate number of bits from your random number. Hope this helps, - Rick "Markoff Chain" Dickinson +---------------------------------+---------------------------+ | Enterprise ArchiTechs Company |"You can't reason someone | | Lotus Certified Notes | out of a position they | | Appl. Design & Administration | didn't reason themselves | |(818)563-1061 rtd@notesguy.com | into" -- Rick Adams, | | http://www.eArchiTechs.com | in alt.folklore.urban | +---------------------------------+---------------------------+