2

I have 10 teams, and I would like to hold a activity to let their battle in the games.

  • Teams competes in 6 rounds
  • In each round 5 pairs competes
  • Only unique pairs

Can I do this in Excel or R?

micstr
  • 5,080
  • 8
  • 48
  • 76
  • Please review this guide (https://stackoverflow.com/help/how-to-ask) to see how to ask a good question at SO. If you want to ask a question related to R, here is a great post about how to provide a reproducible example (https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – www Sep 22 '17 at 05:34
  • 10 teams means 9+8+...+1 = 45 unique pairs. 6 rounds at 5 pairs per round = 30 pairs. What additional rules are you applying to achieve the reduction of 15 pairs? Dividing the 10 teams into two groups of 5 would result in 15 pairs per group so 30 pairings overall. – DMM Sep 22 '17 at 08:52

1 Answers1

6

What you need to apply is algorithm scheduling for round-robin tournament. Explanation of algorithm (elements rotation) is pretty easy and can be found here. Summarising, having 14 teams, we arrange them in matrix as follows.

enter image description here

Then algorithm does specific rotation, keeping first element in the same spot: enter image description here

enter image description here

Here is reproduced solution done with R. Below example is for all combinations, but you can customise to your needs (n=10, r=13) or run for all rounds and pick-up random 6 rounds

library(dplyr)
n <- 14
teams <- 1:n
r <- 13


rounds <- list()
for( i in 1:r){
  round <- 
    data.frame(
      round = i,
      team1 = teams[1:(n/2)], 
      team2 = rev(teams)[1:(n/2)])
  rounds[[i]] <- round
  teams <- c( teams[1],  last(teams), head(teams[-1],-1) ) 
}

rr <- bind_rows(rounds)
head(rr)

# round team1 team2
# 1     1     1    14
# 2     1     2    13
# 3     1     3    12
# 4     1     4    11
# 5     1     5    10
# 6     1     6     9

Enjoy!

GoGonzo
  • 2,637
  • 1
  • 18
  • 25