|
Posted by Ewoud Dronkert on 05/24/05 14:36
On Tue, 24 May 2005 11:58:44 +0100, Matt Raines wrote:
> Reading a line at a time from the file, just update the selected line if
> floor(mt_rand(0, $currentLineNumber - 1)) is 0.
Will never get beyond first line! And if implemented properly, I don't
believe it's fair (but can't be bothered to do the math, sorry).
Neither was my suggestion by the way; every next number is totally
dependent on the previous one:
> $skip = array();
> for ( $i = 0; $i < $words; ++$i )
> {
> $r = mt_rand( 0, $lines - $words );
> $lines -= $r;
> $skip[] = $r;
> }
But it was an easy way to avoid picking the same number twice or more.
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
[Back to original message]
|