# Brain Teaser: how to make a schedule creator

I’ve tried several different approaches and have not been successful with any.

What I need is a routine that will take x amount of items (teams) and schedule them against each other.

This isn’t a tournament (winners don’t advance), just a normal schedule.

The rules are each team must play once per day and only play once per day, and each team must play every team once, and only once.

Also, there will always be an even number of teams.

So, for 6 teams the possible games will be:

1 vs. 2
1 vs. 3
1 vs. 4
1 vs. 5
1 vs. 6
2 vs. 3
2 vs. 4
2 vs. 5
2 vs. 6
3 vs. 4
3 vs. 5
3 vs. 6
4 vs. 5
4 vs. 6
5 vs. 6

In every iteration I can think it has a team missing a day, or teams playing the same team more than once.

What I have figured out is there must be x-1 days (if there are 6 teams it will take 5 days to schedule all games).

Is there an easier way to get this?

You could use a cyclic algorithm where one team stays put.

An example:

Team 1 stays put, teams on the right move down, teams on the left move up. When a team reaches the top/bottom, it goes right/left.

1st round
1-2
6-3
5-4

2nd round
1-6
5-2
4-3

3rd round
1-5
4-6
3-2

4th round
1-4
3-5
2-6

5th round
1-3
2-4
6-5