CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Generating Fixtures

 



andy7t
User

Sep 20, 2003, 2:03 PM

Post #1 of 4 (530 views)
Generating Fixtures Can't Post

Hello,

I'm having a few problems with Foreach.

Right ok:

@premiership1 = "Arsenal","Chelsea","Man U","West Ham";

@premiership2 = "Arsenal","Chelsea","Man U","West Ham";

foreach $premiership1 (@premiership1)
{
foreach $premiership2 (@premiership2)
{

if($premiership2 ne "$premiership")
{
print "<BR>$premiership V $premiership2\n";
}
}
}



Now this would produce a result of:

Arsenal V Chelsea

Arsenal V Man U

Arsenal V West Ham

Chelsea V Arsenal

Chelsea V Man U

Chelsea V West Ham

Man U V Arsenal

Man U V Chelsea

Man U V Westham

etc etc.

Now, these are not very good fixtures- as they are in order!

What i need to do is take $premiership1[0] and then play it against $premiership2[0], then take $premership1[1] and play against $premiership2[0], then $premership1[2] against $premiership2[0] etc etc.

To make a fixture list of something like this:

Arsenal V Chelsea

Man U V West Ham

------------------------------

Chelsea V Man U

West Ham V Arsenal

Note the ----------. This means a new day- so two teams cannot play each other more than once in one day.

Tall order i know, but i would appreciate any help.

Andrew


KevinR
Veteran


Sep 20, 2003, 5:31 PM

Post #2 of 4 (526 views)
Re: [andy7t] Generating Fixtures [In reply to] Can't Post

if you know who should play who, why run through the loop? I am not following you at all.
-------------------------------------------------


andy7t
User

Sep 21, 2003, 1:45 AM

Post #3 of 4 (522 views)
Re: [KevinR] Generating Fixtures [In reply to] Can't Post

Yes, i know who should play who but the trouble is, is that in the method i am using at the moment, one team will play many teams on one day!

I.E

Arsenal V Chelsea

Arsenal V Man U

Arsenal V West Ham

All on the same day!


andy7t
User

Sep 21, 2003, 3:06 AM

Post #4 of 4 (519 views)
Re: [andy7t] Generating Fixtures [In reply to] Can't Post

Perhaps a different wording of the question will help your understanding:

I'm making a script were it needs to generate fixtures.
Now, there are a few rules to follow:
A team cannot play more than one match a day.
A team cannot play each other more than twice in a season.

The list of teams are stored in @premiership.
What needs to be done is generate a fixture's list for each day.

So, for example if @premiership was:
Arsenal, Chelsea, Man U, West Ham, Gillingham
So:
Day 1 could be:
Arsenal V Chelsea
Man U V West Ham

Day 2 could be:
Man U V Gillingham
Aesenal V West Ham

Day 3 could be:
Arsenal V Man U
Chelsea V West Ham

etc etc.
I don't know if anyone would be able to help because i'm completly stumpted.

Thanks,
Andrew

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives