diff --git a/README.md b/README.md new file mode 100644 index 0000000..8bbd9c4 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# round robin tournament + +This is a golang module which will provide functions to generate a 2d slice of string containing matches of given teams. +The matches will be generated using the [round-robin tournament](https://en.wikipedia.org/wiki/Round-robin_tournament). +Every team will play against every other team. + +## example + +The following golang function call will create the 2d slice of strings above. +```go +GenerateRoundRobinTournamentMatchesByNumber(4) +``` + +``` +[ + [Team 1 Team 2] + [Team 3 Team 4] + [Team 1 Team 4] + [Team 2 Team 3] + [Team 1 Team 3] + [Team 4 Team 2] +] +``` + +You will find other examples in [example](example) directory. diff --git a/example/example_bynumber.go b/example/example_bynumber.go new file mode 100644 index 0000000..82cd0d9 --- /dev/null +++ b/example/example_bynumber.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + + "github.com/taskmedia/roundrobintournament" +) + +func main() { + matches := roundrobintournament.GenerateRoundRobinTournamentMatchesByNumber(4) + + for i, match := range matches { + fmt.Printf("match #%d: %s : %s\n", i+1, match[0], match[1]) + } +}