$10K coding deathmatch

Matthew Walker rorith at kydance.net
Fri Nov 3 11:12:06 MST 2006


On Fri, November 3, 2006 10:52 am, Matthew Walker wrote:
> This will generate a random input file for you:
>
> <?php
>
> $lines = mt_rand(10,100);
>
> for ($i = 0; $i < $lines; $i++) {
>         $entries = mt_rand(10,100);
>         for ($j = 0; $j < $entries; $j++) {
>                 if ($j > 0) {
>                         echo " ";
>                 }
>                 echo mt_rand(-100, 100);
>         }
>         echo "\n";
> }
>
> ?>
>
> Run that and pipe the output to a file. Enjoy. :)
>

Just a note about this code....

It'll generate lots of non-matching lists. If you want to increase the
match probability, reduce the range on the inner-most mt_rand(). Maybe
like this:

<?php

$lines = mt_rand(10,100);

for ($i = 0; $i < $lines; $i++) {
        $entries = mt_rand(10,100);
        for ($j = 0; $j < $entries; $j++) {
                if ($j > 0) {
                        echo " ";
                }
                echo mt_rand(-1 * $entries, $entries);
        }
        echo "\n";
}

?>


-- 
Matthew Walker
Kydance Hosting & Consulting
LAMP Specialist



More information about the PLUG mailing list