So I'm looking how to make a checkboard but with a spiral in it instead of the default checkerboard made like this:
$checkerboard=array();
for($row=0;$row<10;$row++){
if($row%2==0){
for($col=0;$col<10;$col++){
if($col%2==0){
$checkerboard[$row][$col]="white";
}else{
$checkerboard[$row][$col]="black";
}
}
}else{
for($col=0;$col<10;$col++){
if($col%2==0){
$checkerboard[$row][$col]="black";
}else{
$checkerboard[$row][$col]="white";
}
}
}
}
I also tried it with 2 diagonals like this:
$diagonal=array();
for($row=0;$row<10;$row++){
for($col=0;$col<10;$col++){
if($row==$col){
$diagonal[$row][$col]='black';
}else{
$diagonal[$row][$col]='white';
}
if($row+$col==9){
$diagonal[$row][$col]='black';
}
}
}
And then echo'd simply like this:
echo "<table>";
for($row=0;$row<count($checkerboard);$row++){
echo "<tr>";
for($col=0;$col<count($checkerboard);$col++){
echo "<td width='50px' height='50px' bgcolor='".$checkerboard[$row][$col]."'></td>";
}
echo "</tr>";
}
I'd like to keep the code simple because I've not been coding php for a very long time and it has to work with an array.
I tried this here:
$spiral=array();
for($row=0;$row<10;$row++){
for($col=0;$col<10;$col++){
$spiral[$row][$col]='white';
if($row==0 or $row==9 or $col==0 or $col==9){
$spiral[$row][$col]='black';
}if($row==1 and $col==0){
$spiral[$row][$col]='white';
}if($row==2 and $col<8){
$spiral[$row][$col]='black';
}if($row>1 and $row<8 and $col==7){
$spiral[$row][$col]='black';
}if($row==7 and $col>1 and $col<8){
$spiral[$row][$col]='black';
}if($row>3 and $row<7 and $col==2){
$spiral[$row][$col]='black';
}if($row==4 and $col>2 and $col<6){
$spiral[$row][$col]='black';
}if($row==5 and $col==5){
$spiral[$row][$col]='black';
}
}
}
But if the checkerboard becomes bigger it will be very hard to change. It there a way to make it easier?
Try this out:
I create an empty board then start drawing horizontal & vertical lines, starting from the edges each time. The code might need some tweaking but it's a good start
$checkerboard=array();
$size = 12;
for ($row=0; $row<$size; $row++) {
for ($col=0; $col<$size; $col++) {
$checkerboard[$row][$col]="red";
}
}
//horizontal
$pair = 0 ;
while ($pair < (int) $size / 2) {
//drawing top half rows
$row = 2 * $pair;
$end = min($row, $size - $row);
$start = $end - 2;
for ($col = $start; ($col < $size - $end) && ($row < $size / 2); $col++){
$checkerboard[$row][$col]="black";
}
//drawing bottom half rows
$far_row = $size - 1 - 2 * $pair;
$end = min($far_row, $size - $far_row) + 1 - 2;
$start = $end ;
for ($col = $start; ($col < $size - $end) && ($far_row > $size / 2 ); $col++){
$checkerboard[$far_row][$col]="black";
}
$pair++;
}
$pair = 0;
//vertical
while ($pair < (int) $size / 2) {
//drawing left half columns
$col = 2 * $pair;
$end = min($col, $size - $col);
$start = $end +2 ;
for ($row = $start; ($row < $size - $end) && ($col < $size / 2); $row++){
$checkerboard[$row][$col]="black";
}
//drawing right half columns
$far_columns = $size - 1 - 2 * $pair;
$end = min($far_columns, $size - $far_columns) - 1;
$start = $end ;
for ($row = $start; ($row < $size - $end) && ($far_columns >= ($size / 2 ) ); $row++){
$checkerboard[$row][$far_columns]="black";
}
$pair++;
}
echo "<table>";
for($row=0;$row< $size;$row++){
echo "<tr>";
for($col=0; $col< $size; $col++){
echo "<td width='50px' height='50px' bgcolor='".$checkerboard[$row][$col]."'></td>";
}
echo "</tr>";
}
You can just change the $size variable for different dimensions
Here is my attempt at the problem:
function buildSpiral($gridSize)
{
/**
* Origin is at the top left handcorner
*/
$x = 0;
$y = 0;
$xMin = 0;
$xMax = $gridSize-1;
$yMin = 2;
$yMax = $gridSize-1;
$pattern = [];
$size = $gridSize;
$collision = function($p, $limit) {
return (bool) ($p == $limit);
};
// increment x
$shadeRight = function(&$x, $y) use (&$pattern, &$xMin, &$xMax, $collision) {
if ($xMin > $xMax) {
return;
}
do {
$pattern[$y][$x] = 1;
} while (!$collision($x++, $xMax));
if ($x >= $xMax) {
$x=$xMax;
}
$xMax-=2;
};
// increment y
$shadeDown = function($x, &$y) use (&$pattern, &$yMin, &$yMax, $collision) {
while ($y < $yMax && $yMin > $yMax) {
$pattern[++$y][$x] = 1;
}
if ($yMin > $yMax) {
return;
}
do {
$pattern[$y][$x] = 1;
} while (!$collision($y++, $yMax));
if ($y >= $yMax) {
$y = $yMax;
}
$yMax-=2;
};
// decrement x
$shadeLeft = function(&$x, $y) use (&$pattern, &$xMin, &$xMax, $collision, $gridSize) {
if ($xMin > $xMax) {
return;
}
do {
$pattern[$y][$x] = 1;
} while (!$collision($x--, $xMin));
if ($x < $xMin) {
$x=$xMin;
}
$xMin+=2;
};
// decrement y
$shadeUp = function($x, &$y) use (&$pattern, &$yMin, &$yMax, $collision, $gridSize) {
while ($y > $yMin && $yMin > $yMax) {
$pattern[--$y][$x] = 1;
}
if ($yMin > $yMax) {
return;
}
do {
$pattern[$y][$x] = 1;
} while(!$collision(--$y, $yMin));
if ($y < $yMin) {
$y = $yMin;
}
$yMin+=2;
};
while ($size > 0) {
$shadeRight($x, $y);
$shadeDown($x, $y);
$shadeLeft($x, $y);
$shadeUp($x, $y);
$size-=2;
}
return $pattern;
}
for ($i = 1; $i <= 25; $i++) {
$checkboard = buildSpiral($i);
echo "<h1>$i</h1>";
echo "<table style='margin-bottom: 2em;'>";
for($row=0;$row<count($checkboard);$row++){
echo "<tr>";
for($col=0;$col<count($checkboard);$col++){
if (!isset($checkboard[$row][$col])) {
echo "<td width='50px' height='50px' bgcolor=\"red\"></td>";
} else {
echo "<td width='50px' height='50px' bgcolor=\"black\"></td>";
}
}
echo "</tr>";
}
echo "</table>";
}
I stop each shading direction when a limit is hit.
Update Let's say I want the spirals to start from the top right corner, then we just need to set the new origin and call the shaders in the way we want the spiral to go like so:
function buildSpiral($gridSize)
{
/**
* Origin is at the top left handcorner
*/
$x = $gridSize-1;
$y = 0;
$xMin = 0;
$xMax = $gridSize-1;
$yMin = 2;
$yMax = $gridSize-1;
$pattern = [];
$size = $gridSize;
$collision = function($p, $limit) {
return (bool) ($p == $limit);
};
// increment x
$shadeRight = function(&$x, $y) use (&$pattern, &$xMin, &$xMax, $collision) {
if ($xMin > $xMax) {
return;
}
do {
$pattern[$y][$x] = 1;
} while (!$collision($x++, $xMax));
if ($x >= $xMax) {
$x=$xMax;
}
$xMax-=2;
};
// increment y
$shadeDown = function($x, &$y) use (&$pattern, &$yMin, &$yMax, $collision) {
while ($y < $yMax && $yMin > $yMax) {
$pattern[++$y][$x] = 1;
}
if ($yMin > $yMax) {
return;
}
do {
$pattern[$y][$x] = 1;
} while (!$collision($y++, $yMax));
if ($y >= $yMax) {
$y = $yMax;
}
$yMax-=2;
};
// decrement x
$shadeLeft = function(&$x, $y) use (&$pattern, &$xMin, &$xMax, $collision, $gridSize) {
if ($xMin > $xMax) {
return;
}
do {
$pattern[$y][$x] = 1;
} while (!$collision($x--, $xMin));
if ($x < $xMin) {
$x=$xMin;
}
$xMin+=2;
};
// decrement y
$shadeUp = function($x, &$y) use (&$pattern, &$yMin, &$yMax, $collision, $gridSize) {
while ($y > $yMin && $yMin > $yMax) {
$pattern[--$y][$x] = 1;
}
if ($yMin > $yMax) {
return;
}
do {
$pattern[$y][$x] = 1;
} while(!$collision(--$y, $yMin));
if ($y < $yMin) {
$y = $yMin;
}
$yMin+=2;
};
while ($size > 0) {
$shadeLeft($x, $y);
$shadeDown($x, $y);
$shadeRight($x, $y);
$shadeUp($x, $y);
$size-=2;
}
return $pattern;
}
for ($i = 1; $i <= 25; $i++) {
$checkboard = buildSpiral($i);
echo "<h1>$i</h1>";
echo "<table style='margin-bottom: 2em;'>";
for($row=0;$row<count($checkboard);$row++){
echo "<tr>";
for($col=0;$col<count($checkboard);$col++){
if (!isset($checkboard[$row][$col])) {
echo "<td width='50px' height='50px' bgcolor=\"red\"></td>";
} else {
echo "<td width='50px' height='50px' bgcolor=\"black\"></td>";
}
}
echo "</tr>";
}
echo "</table>";
}
Related
Someone please help me to create a two triangle patter using PHP. I'm already code but the output didn't as expected below.
expected output
My code:
function generatePattern($num) {
for ($id1 = 0; $id1 <= $num; $id1 = $id1 + 1) {
for ($id2 = $num; $id2 >= $id1; $id2 = $id2 - 1) {
print(' ');
}
for ($id3 = 1; $id3 <= $id1; $id3 = $id3 + 1) {
if ($id3 % 4 == 3) {
echo "o";
} else if ($id3 % 2 == 1) {
echo "x";
} else {
echo " ";
}
}
echo "\n";
}
for ($id1 = 0; $id1 <= $num-1; $id1 = $id1 + 1) {
echo str_repeat(' ', $num - 1);
for($id3 = $num-1; $id3 >= $id1; $id3 = $id3 - 1){
if ($id3 % 4 == 3) {
echo "o";
} else if ($id3 % 2 == 1) {
if ($id1 % 4 == 3) {
echo "o";
} else if ($id1 % 2 == 0) {
echo " ";
} else if ($id1 % 2 == 1) {
echo "x";
} else {
echo "x";
}
} else if ($id3 == $id1){
echo "x";
} else {
echo " ";
}
}
echo "\n";
}
}
generatePattern(4);
And my current output like this (the bottom triangle still messed up)
output
Do the required changes for space between o and x
function generatePattern($num) {
if($num % 2 == 0)
{
$num1 = $num + 1;
}else{
$num1 = $num;
$num = $num - 1;
}
for ($id1 = 1; $id1 <= $num; $id1++) {
for ($id2 = $num; $id2 >= $id1; $id2--) {
print(' ');
}
for ($id3 = 1; $id3 <= $id1; $id3++) {
if ($id3 % 4 == 3) {
echo "o";
} else if ($id3 % 2 == 1) {
echo "x";
} else {
echo " ";
}
}
echo "\n";
}
$str = str_repeat('x o ', ceil(($num1*2)/4));
echo substr($str, 0, $num1*2);
echo "\n";
$j = $num;
for($id1 = $num; $id1 >=1; $id1 = $id1 - 2)
{
for($id2 = 2; $id2 >= 1; $id2--)
{
if($j % 2 == 0)
{
$pattern = [' ', 'x', ' ', 'o',];
}else{
$pattern = [' ', 'o', ' ', 'x',];
}
echo str_repeat(' ', ($id2%2 == 0) ? $num: $num - 1);
$design = implode('', $pattern);
do{
$design .= implode('', $pattern);
}while(strlen($design) < $id1);
echo substr($design, 0, $id1);
echo "\n";
}
$j--;
}
}
generatePattern(14);
When my code is moved from local server to live server it shows an error like this :
Fatal error: Call to undefined method DateTime::diff()
Code:
<?php
date_default_timezone_set('Asia/Calcutta');
$sFinalDate = date('Y-m-d', strtotime($sDate));
$sNow = new DateTime();
$iRemain = new DateTime( $sFinalDate.$sTime);
$iInterval = $iRemain->diff($sNow);
$sTimeCounter = $iInterval->format("%h: %i :%s ");
$sCalculate = $iInterval->format("%a:%h:%i");
?>
Though I found a number of people who ran into the issue of 5.2 and
lower not supporting this function, I was unable to find any solid
examples to get around it. Therefore I hope this can help some others:
<?php
function get_timespan_string($older, $newer) {
$Y1 = $older->format('Y');
$Y2 = $newer->format('Y');
$Y = $Y2 - $Y1;
$m1 = $older->format('m');
$m2 = $newer->format('m');
$m = $m2 - $m1;
$d1 = $older->format('d');
$d2 = $newer->format('d');
$d = $d2 - $d1;
$H1 = $older->format('H');
$H2 = $newer->format('H');
$H = $H2 - $H1;
$i1 = $older->format('i');
$i2 = $newer->format('i');
$i = $i2 - $i1;
$s1 = $older->format('s');
$s2 = $newer->format('s');
$s = $s2 - $s1;
if($s < 0) {
$i = $i -1;
$s = $s + 60;
}
if($i < 0) {
$H = $H - 1;
$i = $i + 60;
}
if($H < 0) {
$d = $d - 1;
$H = $H + 24;
}
if($d < 0) {
$m = $m - 1;
$d = $d + get_days_for_previous_month($m2, $Y2);
}
if($m < 0) {
$Y = $Y - 1;
$m = $m + 12;
}
$timespan_string = create_timespan_string($Y, $m, $d, $H, $i, $s);
return $timespan_string;
}
function get_days_for_previous_month($current_month, $current_year) {
$previous_month = $current_month - 1;
if($current_month == 1) {
$current_year = $current_year - 1; //going from January to previous December
$previous_month = 12;
}
if($previous_month == 11 || $previous_month == 9 || $previous_month == 6 || $previous_month == 4) {
return 30;
}
else if($previous_month == 2) {
if(($current_year % 4) == 0) { //remainder 0 for leap years
return 29;
}
else {
return 28;
}
}
else {
return 31;
}
}
function create_timespan_string($Y, $m, $d, $H, $i, $s)
{
$timespan_string = '';
$found_first_diff = false;
if($Y >= 1) {
$found_first_diff = true;
$timespan_string .= pluralize($Y, 'year').' ';
}
if($m >= 1 || $found_first_diff) {
$found_first_diff = true;
$timespan_string .= pluralize($m, 'month').' ';
}
if($d >= 1 || $found_first_diff) {
$found_first_diff = true;
$timespan_string .= pluralize($d, 'day').' ';
}
if($H >= 1 || $found_first_diff) {
$found_first_diff = true;
$timespan_string .= pluralize($H, 'hour').' ';
}
if($i >= 1 || $found_first_diff) {
$found_first_diff = true;
$timespan_string .= pluralize($i, 'minute').' ';
}
if($found_first_diff) {
$timespan_string .= 'and ';
}
$timespan_string .= pluralize($s, 'second');
return $timespan_string;
}
function pluralize( $count, $text )
{
return $count . ( ( $count == 1 ) ? ( " $text" ) : ( " ${text}s" ) );
}
?>
source http://php.net/manual/en/function.date-diff.php
if you using php 5.3 then there would be another issue
working above example on php>=5.3
I'm having trouble making a simple count work. Right now 0 is constantly displayed when I run the code and I know it's because I set count to 0. But it should be displaying the number of times "Fizz" is displayed.
I'm sure it's simple but I just can't see what!
public function __construct($firstParam, $secondParam, $firstSound = "Fizz", $secondSound = "Buzz", $numbers = 100) {
$this->firstParam = $firstParam;
$this->secondParam = $secondParam;
$this->firstSound = $firstSound;
$this->secondSound = $secondSound;
$this->numbers = $numbers;
$this->numsArray = $numsArray;
}
public function __toString() {
$count = 0;
for ($i = 0; $i < count($this->numsArray); $i++){
$val = $this->numsArray[$i];
if ($val == $this->firstSound) {
$count++;
}
}
$print = "Number of Fizzes: ".$count;
return $print;
}
public function execute() {
$this->numsArray = array();
if ($this->secondParam > $this->firstParam) {
for ($i = 1; $i <= $this->numbers; $i++){
if ($i % $this->firstParam == 0 && $i % $this->secondParam == 0) {
$this->numsArray[] = "\n".$this->firstSound.$this->secondSound."\n";
} elseif ($i % $this->firstParam == 0) {
$this->numsArray[] = "\n".$this->firstSound."\n";
} elseif ($i % $this->secondParam == 0) {
$this->numsArray[] = "\n".$this->secondSound."\n";
} else {
$this->numsArray[] = "\n".$i."\n";
}
echo $this->numsArray[$i-1];
}
} else {
echo "\n".' First Number Bigger Than Second '."\n";
}
}
In your execute you are not assigning the values to numsArray[i] also you inject new line characters that will not match the equality you just when checking $val. Also I notice you use zero index to check them and index 1 to load it. Change execute to:
for ($i = 0; $i < $this->numbers; $i++){
if ($i % $this->firstParam == 0 && $i % $this->secondParam == 0) {
$this->numsArray[i] = $this->firstSound.$this->secondSound;
} elseif ($i % $this->firstParam == 0) {
$this->numsArray[i] = $this->firstSound;
} elseif ($i % $this->secondParam == 0) {
$this->numsArray[i] = $this->secondSound;
} else {
$this->numsArray[i] = $i;
}
echo $this->numsArray[$i];
This is a better binary string comparison for php...
if (strcmp($val, $this->firstSound) == 0)
Basically this is related to a squash application where we have 2 scores. One is from winner point of view and another from loser point of view.
eg.
Score1: 11-5,11-5,11-5 (Winner point of view)
Score2: 5-11, 5-11,5-11 (Loser point of view)
Now in my logic i want to find which is the winner score and which is the loser score.
I have written my logic in the below way and it does work. But i want to know if their is any other better/optimized way of writing this.
$high1 = 0;
$high2 = 0;
$score1 = "2-11,5-11,4-11,4-4";
$score2 = "11-2,11-5,11-4,4-4";
$score1Array = explode(",",$score1);
$size = sizeof($score1Array);
for($i = 0; $i < $size; $i++) {
$checkscore1 = explode("-",$score1Array[$i]);
if($checkscore1[0] < $checkscore1[1]) {
$high1++;
}else if($checkscore1[0] > $checkscore1[1]) {
$high2++;
}
}
if($high1 > $high2) {
$winningScore = $score2;
$losingScore = $score1;
}else{
$winningScore = $score1;
$losingScore = $score2;
}
echo $winningscore;
echo $losingscore;
What about something like this:
function is_winning($score) {
$split_scores = preg_split('/(-|,)/', $score);
$wins = $losses = 0;
for($i = 0; $i < count($split_scores) / 2; $i += 2) {
if($split_scores[$i] > $split_scores[$i + 1])
$wins++;
if($split_scores[$i] < $split_scores[$i + 1])
$losses++;
}
return $wins > $losses;
}
Assuming $score is formatted as in your question. You can then use it like this:
$score1 = "2-11,5-11,4-11,4-4";
$score2 = "11-2,11-5,11-4,4-4";
if(is_winning($score1)) {
$winning_score = $score1;
$losing_score = $score2;
} else {
$winning_score = $score2;
$losing_score = $score1;
}
echo $winning_score;
echo $losing_score;
The idea is to split the score into an array where the even numbered indexes have the left score and the odd numbered indexes the right score. We then count the number of wins and the number of losses. If there's more wins then losses then we return true since the score was a winning score. If there's not more wins then losses we simply return false.
This should work
$score1 = "2-11,5-11,4-11,4-4";
$score2 = "11-2,11-5,11-4,4-4";
$l = $r = 0;
$score1_sets_arr = explode(',', $score1);
foreach ($score1_sets_arr as $set_score) {
$set_score_arr = explode('-', $set_score);
if ($set_score_arr[0] > $set_score_arr[1]) {
$l++;
} else {
$r++;
}
}
if ($l > $r) {
$winning_score = $score1;
$losing_score = $score2;
} else {
$winning_score = $score2;
$losing_score = $score1;
}
you can use this :
<?php
$high1 = 0;
$high2 = 0;
$score1 = "2-11,5-11,4-11,4-4";
$score2 = "11-2,11-5,11-4,4-4";
$explode = explode(",",$score1);
for($i=0;$i< sizeof($explode);$i++){
$explode2= explode("-", $explode[$i]);
if($explode2[0] <= $explode2[1]){
echo $explode2[0]."-";
echo $explode2[1]." ";
}
}
echo "<br />";
for($i=0;$i< sizeof($explode);$i++){
$explode2= explode("-", $explode[$i]);
if($explode2[1] >= $explode2[0]){
echo $explode2[1]."-";
echo $explode2[0]." ";
}
}
?>
for Winner point of view, all big score in left,otherwise in right. so u can just detect the first score.
$score1Array = explode(",",$score1);
$checkscore1 = explode("-",$score1Array[$i]);
if($checkscore1[0] < $checkscore1[1]) {
echo $score2;
echo $score1;
}else{
echo $score1;
echo $score2;
}
Fix: above code is wrong,try this:
$score1value = eval(str_replace(",","+",$score1));
$score2value = eval(str_replace(",","+",$score2));
if($score1value < $score2value) {
echo $score2;
echo $score1;
}else{
echo $score1;
echo $score2;
}
How do I get this PHP code to output HTML in order to enter the player's number and generate the tournament?
<?php
class RoundRobin
{
var $MaxTeams;
var $MaxCombinations;
var $tourn;
var $mList;
var $cList;
var $cUsed;
function RoundRobin($max)
{
$this->MaxTeams=$max;
$this->MaxCombinations=($this->MaxTeams/2)*($this->MaxTeams-1);
}
function ShowSchedule($players,$totalChecks)
{
echo $players.' players'."\n";
for ($r=1; $r <= $players/2; $r++) echo 'Game'.$r;
echo "\n";
echo" +-";
for ($r=1; $r <= ($players/2)*6-2; $r++) echo '-';
echo "\n";
$index = 1;
for ($r=1; $r <= $players-1; $r++)
{
echo 'Week '.$r. '|';
for ($m=1; $m <= $players/2; $m++)
{
echo $this->tourn[$index]['one'].'&'. $this->tourn[$index]['two'];
$index++;
}
echo "\n";
}
echo "\n".$totalChecks,' combinations tried'. "\n\n";
}
function array_copy(&$dest,$source)
{
if(count($source)>count($dest)) {echo 'fatal'; exit;}
//for($a=0;$a<count($source);$a++)
$dest['one']=$source['one'];
$dest['two']=$source['two'];
}
function ClearArrays()
{
for ($i=0; $i <= $this->MaxCombinations; $i++)
{
$this->tourn[$i]['one']=0;
$this->tourn[$i]['two']=0;
$this->cList[$i]['one']=0;
$this->cList[$i]['two']=0;
$this->cUsed[$i]=0;
if($i<=$this->MaxTeams/2)$this->mList[$i] = 0;
}
}
function Scheldule($players)
{
while ($players <= $this->MaxTeams)
{
$combinations = $players/2 * ($players-1);
$totalChecks = 0;
$this->ClearArrays();
/* set up list of all combinations */
$m=1;
for ($a=1; $a<$players; $a++)
for ($b=$a+1; $b<=$players; $b++)
{
$this->cList[$m]['one'] = $a;
$this->cList[$m]['two'] = $b;
$m++;
}
$roundCount=1;
$index=1;
while ($roundCount <= $players-1)
{
$matchCount = 1;
$round_set = 0;
for ($i=0; $i<=$this->MaxTeams/2; $i++) $this->mList[$i] = 0;
$startC = $roundCount;
while ($matchCount <= $players/2)
{
$c = $combinations + 1;
while ($c > $combinations)
{
$c = $startC;
/* find an unused pair that would be legitimate */
while (
($c <= $combinations)
&&
( //
($round_set & (1 << $this->cList[$c]['one'])) ||
($round_set & (1 << $this->cList[$c]['two'])) ||
(!empty($this->cUsed[$c]))
)
) $c++;
if ($c > $combinations)
{
do {
$this->mList[$matchCount] = 0;
$matchCount--;
$index--;
$round_set &= ~(1 << $this->cList[$this->mList[$matchCount]]['one']);
$round_set &= ~(1 << $this->cList[$this->mList[$matchCount]]['two']);
$this->cUsed[$this->mList[$matchCount]] = false;
$this->tourn[$index]['one'] = 0;
$this->tourn[$index]['two'] = 0;
}
while ($this->cList[$this->mList[$matchCount]]['one'] != $this->cList[$this->mList[$matchCount]+1]['one']);
$startC = $this->mList[$matchCount]+1;
}
}
$this->array_copy(&$this->tourn[$index],$this->cList[$c]);
$totalChecks++;
if (($totalChecks % 1000) == 0) printf("%d\033A\n", $totalChecks );
$this->cUsed[$c] = true;
$this->mList[$matchCount] = $c;
$startC = 1;
$round_set |= (1 << $this->cList[$c]['one']);
$round_set |= (1 << $this->cList[$c]['two']);
$index++;
$matchCount++;
}
$roundCount++;
}
/* yahoo!, scheduled all the rounds */
printf(" " );
$this->ShowSchedule($players,$totalChecks);
/* try and make a schedule using two more teams */
$players += 2;
}
}
}
?>
It's a PHP class. Reading the manual might help you.
Something along the lines of this might work:
$rr = new RoundRobin( 5 );
$rr->Scheldule( $_POST['PlayerCount'] );
But I can't be bothered deciphering the code to work out if it really will.
Also, if you haven't yet learnt HTML forms, read a tutorial like w3schools.