I'm trying to write a script which creates national lottery numbers.
I need to make the script do these things.
each line needs to be unique.
Able to ignore numbers.
need to able to select 100 line of lottery.
only 4 numbers can match previous lines.
I have been working on this for few days now but i can't get it to ignore numbers and get unique numbers on each line.
My biggest problem is that i need to make sure the numbers are not repeated. each line can have 4 or numbers as before line or after line.
PHP Code:
$max_number=50; //select numbers between 1-50
$ignor_numbers=array(3,5,6,9,21); //ignore these numbers
$maxn=6; //max numbers per line
$max_line=5000; // max number of lines
$max_lines=0; // start point of line
$line =array();
$unique_numbers =4; //each line needs have unique numbers
while ( $max_lines < $max_line)
{
srand((double) microtime() * 1000000);
while (1>0) {
$lottery[] = rand(1, $max_number);
$lottery = array_unique($lottery);
if( in_array($lottery, $line ) ){
}
if (sizeof($lottery) == $maxn) {
sort($lottery);
$line[]=$lottery;
break;
}
}
unset($lottery);
$max_lines++;
}
sort ( $line );
for( $i=0; $i < sizeof($line); $i++ ){
$each_line = $line[$i];
for( $j=0; $j < sizeof( $each_line ); $j++ )
{
echo " ".$each_line[$j];
}
echo "<br>";
}