0

we have a 16 player league and a 15 week round robin schedule. Each player plays against each other (round robin)once. I want to see if each member can play in the same foursome with another player exactly 3 times. Every round robin program I've run ends up with some players playing with each other 5 times and others only once. is there a way for this to work so within the round robin format all players play in the same foursome exactly 3 times. thanks

2 Answers2

0

Here's how I would tackle this problem in C++. This is a simple program that randomizes teams into leagues, and then generates a randomized schedule where every team plays three other teams an even amount of times. You could further customize it however you wanted.

#include <vector>
#include <string>


std::vector<std::string> createSchedule(std::vector<std::string> teams, int numberOfGames)
{
    //Create the randomized schedule

    std::vector<std::string> schedule;
    int counter = 0;
    for (int i = 0; i < numberOfGames; i++) {
        std::string game1;
        std::string game2;
        if (counter == 0) {
            game1 = teams[0] + " vs " + teams[1];
            game2 = teams[2] + " vs " + teams[3];
        }
        else if (counter == 1) {
            game1 = teams[0] + " vs " + teams[2];
            game2 = teams[1] + " vs " + teams[3];
        }
        else if (counter == 2) {
            game1 = teams[0] + " vs " + teams[3];
            game2 = teams[1] + " vs " + teams[2];
        }
        schedule.push_back(game1);
        schedule.push_back(game2);

        if (counter == 2) {
            counter = 0;
        }
        else {
            counter++;
        }
    }

    return schedule;
}

int main()
{
    std::vector<std::string> teams = { "Team1", "Team 2", "Team 3", "Team 4", "Team 5", "Team 6", "Team 7", "Team 8", "Team 9", "Team 10", "Team 11", "Team 12", "Team 13", "Team 14", "Team 15", "Team 16" };

    std::vector<std::string> group1;
    std::vector<std::string> group2;
    std::vector<std::string> group3;
    std::vector<std::string> group4;

    //randomize teams into groups
    for (int i = 0; i < teams.size(); i++) {
        int num = rand() % 15;

        if (num >= 0 && num < 4 && group1.size() < 4) {
            group1.push_back(teams[i]);
        }
        else if (num >= 4 && num < 8 && group2.size() < 4) {
            group2.push_back(teams[i]);
        }
        else if (num >= 8 && num < 12 && group3.size() < 4) {
            group3.push_back(teams[i]);
        }
        else if (num >= 12 && num < 16 && group4.size() < 4) {
            group4.push_back(teams[i]);
        }
        else {
            if (group1.size() < 4) {
                group1.push_back(teams[i]);
            }
            else if (group2.size() < 4) {
                group2.push_back(teams[i]);
            }
            else if (group3.size() < 4) {
                group3.push_back(teams[i]);
            }
            else if (group4.size() < 4) {
                group4.push_back(teams[i]);
            }

        }
    }

    //Create a schedule of 15 games for each group
    std::vector<std::string> schedule1 = createSchedule(group1, 15);
    std::vector<std::string> schedule2 = createSchedule(group2, 15);
    std::vector<std::string> schedule3 = createSchedule(group3, 15);
    std::vector<std::string> schedule4 = createSchedule(group4, 15);

    //Combine them into one big master schedule group by each set of games
    //The first 8 games would be the first week of games for the whole league, etc...
    std::vector<std::string> masterSchedule;

    for (int i = 0; i < schedule1.size(); i += 2) {
        masterSchedule.push_back(schedule1[i]);
        masterSchedule.push_back(schedule1[i + 1]);
        masterSchedule.push_back(schedule2[i]);
        masterSchedule.push_back(schedule2[i + 1]);
        masterSchedule.push_back(schedule3[i]);
        masterSchedule.push_back(schedule3[i + 1]);
        masterSchedule.push_back(schedule4[i]);
        masterSchedule.push_back(schedule4[i + 1]);
    }

    return 0;
}
  • Sorry I am not a programmer/mathematician... I just stumbled on the site looking for an answer to my golf league schedule question. If you aren't here to provide the answer to the question, I understand. – Mark Fleming Mar 15 '17 at 14:02
  • This is a site for programming questions, so I gave you a programming answer. I'm not sure what else you wanted. – jmbockhorst Mar 15 '17 at 14:44
  • i thought maybe you might be able to give me the schedule i'm looking for. No worries... – Mark Fleming Mar 16 '17 at 01:23
-1

I think you might be looking for a Whist design. Go here and click on 'Whist' and '16 items'. Tables become foursomes, the pairs are games of your round-robin. The same 15 round schedule is repeated below.

[(16  1) ( 9 14)] [( 2  4) ( 5  8)] [( 3 10) (12 13)] [( 6 15) ( 7 11)] 
[(16  2) (10 15)] [( 3  5) ( 6  9)] [( 4 11) (13 14)] [( 7  1) ( 8 12)] 
[(16  3) (11  1)] [( 4  6) ( 7 10)] [( 5 12) (14 15)] [( 8  2) ( 9 13)] 
[(16  4) (12  2)] [( 5  7) ( 8 11)] [( 6 13) (15  1)] [( 9  3) (10 14)] 
[(16  5) (13  3)] [( 6  8) ( 9 12)] [( 7 14) ( 1  2)] [(10  4) (11 15)] 
[(16  6) (14  4)] [( 7  9) (10 13)] [( 8 15) ( 2  3)] [(11  5) (12  1)] 
[(16  7) (15  5)] [( 8 10) (11 14)] [( 9  1) ( 3  4)] [(12  6) (13  2)] 
[(16  8) ( 1  6)] [( 9 11) (12 15)] [(10  2) ( 4  5)] [(13  7) (14  3)] 
[(16  9) ( 2  7)] [(10 12) (13  1)] [(11  3) ( 5  6)] [(14  8) (15  4)] 
[(16 10) ( 3  8)] [(11 13) (14  2)] [(12  4) ( 6  7)] [(15  9) ( 1  5)] 
[(16 11) ( 4  9)] [(12 14) (15  3)] [(13  5) ( 7  8)] [( 1 10) ( 2  6)] 
[(16 12) ( 5 10)] [(13 15) ( 1  4)] [(14  6) ( 8  9)] [( 2 11) ( 3  7)] 
[(16 13) ( 6 11)] [(14  1) ( 2  5)] [(15  7) ( 9 10)] [( 3 12) ( 4  8)] 
[(16 14) ( 7 12)] [(15  2) ( 3  6)] [( 1  8) (10 11)] [( 4 13) ( 5  9)] 
[(16 15) ( 8 13)] [( 1  3) ( 4  7)] [( 2  9) (11 12)] [( 5 14) ( 6 10)] 
IW33
  • 1
  • 1