Skip to content

Commit

Permalink
add readme and first example code
Browse files Browse the repository at this point in the history
Adding a short description of the project to the readme file for better display on GitHub.
Also adding a first example how to use go module by using `GenerateRoundRobinTournamentMatchesByNumber()`.
  • Loading branch information
fty4 committed Oct 28, 2021
1 parent 4391e75 commit 6ab2433
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions example/example_bynumber.go
Original file line number Diff line number Diff line change
@@ -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])
}
}

0 comments on commit 6ab2433

Please sign in to comment.