I have a function getMeetingsPossibilities()
that return an array. For example is I have 4 teams it will return ['0-1', '0-2', '0-3', '1-2', '1-3', '2-3']
.
I am trying to write a function that would return an array with a set of meetings for n
time wanted.
For example getSetsOfMeetings(3) (with 4 teams) would return something like [['0-1','2-3'], ['0-2','1-3'], ['0-3','1-2']]
I can not figure it out how to do this, I tried many time in vain…
I was thinking of something like this :
let meetingsPossibilities = getMeetingsPossibilities(participantsList.length);
//return for 4 teams : ['0-1', '0-2', '0-3', '1-2', '1-3', '2-3']
//Taking out a meeting from meetingPossibilities each time it is used
let oneSetOfMeeting = [];
oneSetOfMeeting.push(meetingPossibilities.splice(randomNumber, 1);
But I can’t get the logic to have for each oneSetOfMeeting
each teams playing only once.
Would you have some idea of a way to do it ?