Posted by Andy Hassall on 07/17/06 19:59
On 17 Jul 2006 12:49:33 -0700, "AP" <megacrosstab@greenixsolutions.com> wrote:
>Any suggestions on the most efficient way to generate a random number
>from a range that will not return values specified in an array?
Depends how many values you have in the array compared with the overall range
of random numbers. If the number of values is small and the random value range
large, a simple "try-check array-retry as necessary" loop is likely to be the
most practical approach - although it'll degrade in performance as the
proportions of the two change and a significant percentage of the range is
marked as "used".
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
[Back to original message]
|