En cours

Improve My "Round Robin Generator" Function!

- I have a list of eight teams. (e.g. Teams 1, Team 2, ..., Team 8)

- I have a list of seven weekly dates (e.g. Sep 10, Sep 17, ..., Oct 28)

- I have a list of four different times (e.g. 5:45, 6:45, 7:45, 8:30)

- I've pasted my roundRobin function below.

- I also pasted the code that I use to create the round robin (underneath the function) with the teams, dates, and times listed above.

- Running this code results in a schedule similar to one that I've attached. (Each time it is slightly different since the times are randomized.)

- What I want is for the resulting times to be more fairly distributed and spread out. For example, as you can see in the attached photo, Team #5 plays at 7:45 5 out of 7 weeks. That isn't acceptable. Also, if possible, I don't want a team to play at the same time for two consecutive weeks. For example, Team #5 again plays at 7:45 on Sep 16 and then again at 7:45 on Sep 23. I don't want that to occur.

function roundRobin(array$teams)

{

if (count($teams)%2!=0) {array_push($teams,"Bye");}$two=array_splice($teams,(count($teams)/2));$one=$teams;

for ($i=0;$i<count($one)+count($two)-1;$i++)

{

for ($j=0;$j<count($one);$j++) {$round[$i][$j]["1"]=$one[$j];$round[$i][$j]["2"]=$two[$j];}

if(count($one)+count($two)-1>2) {$s=array_splice($one,1,1);$slice=array_shift($s);array_unshift($two,$slice);array_push($one,array_pop($two));}

}

return $round;

}

$numtimes=mysql_num_rows(mysql_query("SELECT `id` FROM `times`"));

$teamsquery = mysql_query("SELECT * FROM `teams`");

while ($row = mysql_fetch_assoc($teamsquery))

{

if (!$list) {$list=array();array_push($list, $row['num']);}else {array_push($list, $row['num']);}}

$rounds = roundRobin($list);

foreach($rounds as $round => $games)

{

$date = mysql_result(mysql_query("SELECT `id` FROM `dates` ORDER BY `date` ASC LIMIT ".($round).",1"),0);

foreach ($games as $team)

{

$time = mysql_result(mysql_query("SELECT `id` FROM `times` WHERE ".$limitation." ORDER BY RAND() LIMIT 1"),0);

$limitation.=" AND `id`!='".$time."'";

$insert = mysql_query("INSERT INTO `schedule` VALUES (NULL, '".$date."', '".$time."', '".mres($team[1])."', '".mres($team[2])."', '');");

}

$limitation='';

}

}

Compétences : HTML, MySQL, PHP, Architecture Logicielle

Voir plus : asc it, ad9833 function generator circuits, dds function generator ad9833, ad9833 function generator, compact dds function generator, dds function generator 1hz, function generator ad9833, ad9833 based function generator, microcontroller ultrasonic function generator, function generator using 8051

Concernant l'employeur :
( 0 commentaires ) Regina, Canada

N° du projet : #8474769

10 freelance ont fait une offre moyenne de 209 $ pour ce travail

toinnisfree

I have read your project details, and I am interested in offering my services. I provide 100% satisfaction guaranteed on all my work. Milestone is required to begin; to be released when the job has been satisfactor Plus

250 $ CAD en 3 jours
(737 Commentaires)
8.3
gopalvora

Hi I have gone through the details of your project and we find it well within our capabilities. I offer a wide range of services, including Web design, PHP/MySQL web application development, Open sources like Joo Plus

216 $ CAD en 8 jours
(400 Commentaires)
8.0
posspooja

Hello, I am an PHP Certified Developer with more than 7 years of experience and shall get this done in about 3 days' time. Let me know if you have any doubts / queries about my expertise, will be more than happ Plus

210 $ CAD en 3 jours
(122 Commentaires)
7.4
Jeet81

Hi i know how round robin functionality works i have checked your progrma as well as your image also , I can fix the code as you want Please reply to discuss. Thanks

185 $ CAD en 4 jours
(181 Commentaires)
6.8
malviyamanish

Dear Client Greetings, Hopefully you are doing well. I have working experience of more than 6 years in Web Site design & development and have developed more than 300 websites here on freelancer.com & more than 400 pr Plus

526 $ CAD en 3 jours
(119 Commentaires)
6.6
techwelf

A proposal has not yet been provided

234 $ CAD en 5 jours
(77 Commentaires)
6.3
avinashjain09

Hello, Please provide more details about the work. Please provide the sample/reference link. Can we have more discussion. I have 4 years of experience in php,mysql,codeigniter,wordpress,laravel,API integration,social m Plus

100 $ CAD en 3 jours
(68 Commentaires)
5.9
kotharigaurav90

Hello Sir , I understand your all requirements , Can We Discuss About The Project ? please check your private memorandum.

111 $ CAD en 3 jours
(44 Commentaires)
5.7
duykhanhonline

I have great experiences on this kind of jobs.Glad if have a chance to work with you on this kind of jobs. Best regards, Khanh

100 $ CAD en 3 jours
(36 Commentaires)
5.3
ithuang2014

A proposal has not yet been provided

147 $ CAD en 3 jours
(43 Commentaires)
4.6
dalmash

Dear Sir, I will be glad to work for you. I have the neccasary experience and I deliver the work with responsibility and honesty. I am online now! Best Regards, Dalmash

155 $ CAD en 3 jours
(5 Commentaires)
3.8