Re: Random Number Excluding Specified Value in Array



On 17 Jul 2006 12:49:33 -0700, "AP" <megacrosstab@xxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxx :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
.



Relevant Pages

  • Re: Error log.
    ... http://www.andyhsoftware.co.uk/space:: disk and FTP usage analysis tool ... Prev by Date: ...
    (comp.lang.php)
  • Re: php diff
    ... example renderers in the package that you can tweak. ... http://www.andyhsoftware.co.uk/space:: disk and FTP usage analysis tool ...
    (comp.lang.php)
  • Re: new forum -- homework help/chit chat/easy communication
    ... http://www.andyhsoftware.co.uk/space:: disk and FTP usage analysis tool ... Prev by Date: ...
    (comp.lang.php)
  • Re: mkdir() problems
    ... What are the permissions on the parent directory? ... http://www.andyhsoftware.co.uk/space:: disk and FTP usage analysis tool ...
    (comp.lang.php)