2

Ok so I have N girls and N guys. I need to create a 2's beach volleyball coed tournament (also known as King and Queen style). I want a list (like Joe and Jill versus Donald and Melania...etc.) of all possible unique games, given the following constraints:

  • Coed 2's, so 2 members per team, 1 girl and 1 guy
  • two teams having the same exact players can only play once against each other (that is a "unique game")

Which formula do I need to use? Here is an example for 2 teams, assuming that one gender is identified by numbers (player 1, player 2...) and the other by letters (player A, player B...)

All possible unique games with N=2:

1A versus 2B
2A versus 1B

All possible unique games with N=3:

1A versus 2B
1A versus 3C
1A versus 2C
1A versus 3B
2A versus 1B
2A versus 3C
2A versus 1C
2A versus 3B
3A versus 2B
3A versus 1C
3A versus 2C
3A versus 1B
1B versus 2C
1B versus 3C
2B versus 3C
2B versus 1C
3B versus 1C
3B versus 2C
Millemila
  • 121
  • 3
  • Do you want to generate this list? Or do you want to calculate what the length of this list would be? – Ryan Volpi Dec 10 '20 at 18:14
  • generate the list – Millemila Dec 10 '20 at 18:20
  • Could you please indicate (1) whether the teams have already been formed or will be formed as part of this process and (2) what a "match" is, given that your second bullet suggests three of the four players on the court could be the same person! – whuber Dec 10 '20 at 18:50
  • 1
    I rephrase it and I added examples...please let me know if now it is clear...with match I meant game – Millemila Dec 11 '20 at 05:37
  • +1 Giving the examples was very helpful. – whuber Dec 11 '20 at 12:09

1 Answers1

3

A game is determined by a pair of distinct males, a pair of distinct females, and a choice of which male to associate with which female. With $n$ males and $m$ females available there are $\binom{n}{2} = n(n-1)/2$ pairs of males, $\binom{m}{2}=m(m-1)/2$ pairs of females, and there are always two distinct ways of associating the males with the females once two pairs have been chosen. Therefore the solution is

$$\frac{n(n-1)}{2}\,\frac{m(m-1)}{2}\, 2 = \frac{nm(n-1)(m-1)}{2}.$$

When $m=n,$ as in the question, this simplifies to

$$\frac{n^2(n-1)^2}{2}.$$

For $n=2, 3, 4, 5, 6, \ldots,$ this series proceeds $2, 18, 72, 200, 450, \ldots$.


This analysis suggests a straightforward algorithm for generating a list of all games, as implemented in this R code. It loops over all pairs of females (components of the argument y) within all pairs of males (components of the argument x).

As an example, the command games(3) generates a data frame corresponding to the $n=3$ example in the question (but the matches are listed in a different order). The implementation of f is fully general; its convenience wrapper games is limited to $n\le 26$ because it uses single capital letters to represent the women.

f <- function(x, y) { # `x` is an array of male ids; `y` is an array of female ids
  D <- as.data.frame(t(matrix(apply(combn(x, 2), 2, 
             function(boys) apply(combn(y, 2), 2, function(girls) 
               cbind(c(boys, girls), c(boys, rev(girls))))), 4)))
  names(D) <- c("Team 1 Male", "Team 2 Male", "Team 1 Female", "Team 2 Female")
  return(D[, c(1,3,2,4)]) # Corresponds to how teams are listed in the question
}
games <- function(n) f(seq_len(n), LETTERS[seq_len(n)])
whuber
  • 281,159
  • 54
  • 637
  • 1,101