Re: Random Number Excluding Specified Value in Array
- From: Andy Hassall <andy@xxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 20:59:07 +0100
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
.
- Follow-Ups:
- References:
- Prev by Date: PHP 5 DomDocument
- Next by Date: Re: Login / Password
- Previous by thread: Random Number Excluding Specified Value in Array
- Next by thread: Re: Random Number Excluding Specified Value in Array
- Index(es):
Relevant Pages
|
|