The 2008 Winter Scripting Games

Advanced Event 7: Play Ball!

Important: The deadline for this event has passed. Solutions are available in VBScript, Windows PowerShell, and Perl.

In Play Ball! competitors must write a script that schedules all the games for a round-robin baseball tournament.

Not a native speaker of English? These event instructions are also available in the following languages: Chinese (Simplified); Chinese (Traditional); French; German; Japanese; Portuguese Brazilian; Russian; and Spanish. For more information, and to access these localized instructions, see the Scripting Games International page.

*
On This Page
About This EventAbout This Event
Event ScenarioEvent Scenario

About This Event

Division

Advanced

Deadline

Thursday, February 28, 2008 (8:00 AM PST)

Points Awarded

10

Top of pageTop of page

Event Scenario

In a round-robin baseball tournament (or any kind of round-robin tournament, for that matter), every team plays each of the other teams in the tournament one time and one time only. For example, suppose we have a tournament with three teams (teams A, B, and C). In that case, the tournament would consist of the following set of games:

A vs. B

A vs. C

B vs. C

See how that works? Team A plays Team B and Team C; Team B plays Team A and Team C; and Team C plays Teams A and B. It’s that easy.

Your task in Event 7 is to schedule a round-robin baseball tournament consisting of 6 teams:

Team A

Team B

Team C

Team D

Team E

Team F

To schedule the tournament you must do two things. First, you must make sure that every team plays each of the other teams once (and only once). For example, that means team A must play the following set of games:

A vs. B

A vs. C

A vs. D

A vs. E

A vs. F

Second, you must list games in the order in which they are to be played. The preceding order is not acceptable. Why not? Because this would mean that team A would have to play the first 5 games of the tournament, which doesn’t seem fair. Therefore, after calculating the games to be played (e.g., A vs. B, A vs. C, etc.) your script must then randomly schedule the games. That way, the final tournament schedule will look something like this:

C vs. D

A vs. F

B vs. D

Etc.

Remember, because the schedule is randomly determined there is no one correct answer. Instead, you will receive full credit for this event as long as: 1) every team is scheduled to play each of the other teams once, and only once; and 2) the actual schedule of games is randomly determined. We should also note that the order in which teams are listed does not matter; in other words, this game:

A vs. B

Is considered the same game as this:

B vs. A

Which also means that, if your schedule looks like this, you did something wrong:

A vs. B

B. vs. A

Hint. As a quick way to double-check your output, we’ll let you in on a secret: the schedule should consist of 15 games.


Top of pageTop of page