Coder Social home page Coder Social logo

roundrobintournament's Introduction

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. Every team will play against every other team.

example

The following golang function call will create the 2d slice of strings above.

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 directory.


releases docs golang version
MIT license codecoverage code size
issues pull requests
twitter

roundrobintournament's People

Contributors

fty4 avatar

Watchers

 avatar  avatar

roundrobintournament's Issues

test with interfaces

most of the tests seem to be working the same way - they might can be shortened by using interfaces.


teams := make([]string, 0)
for i := 1; i <= 10; i++ {
teams = append(teams, fmt.Sprintf("Team %d", i))
}
matches := GenerateRoundRobinTournamentMatches(teams)
expectedLenMatches := expectedMatches(len(teams))
if len(matches) != expectedLenMatches {
t.Fatalf("Length of matches (%d) not as expected (%d)", len(matches), expectedLenMatches)
}

vs

teams := make([]string, 0)
for i := 1; i <= 11; i++ {
teams = append(teams, fmt.Sprintf("Team %d", i))
}
matches := GenerateRoundRobinTournamentMatches(teams)
expectedLenMatches := expectedMatches(len(teams))
if len(matches) != expectedLenMatches {
t.Fatalf("Length of matches (%d) not as expected (%d)", len(matches), expectedLenMatches)
}

add readme

add a basic readme file to describe the project in some sentences

Double rr tournament

Create function to create a double roundrobin tournament (every team plays against every team twice - once as home team and once as guest team)

// first half of the season
TeamA : TeamB
TeamB : TeamC
TeamA : TeamC

// second half of the season
TeamB : TeamA
TeamC : TeamB
TeamC : TeamA

Add ability to create matches by team number

Add ability to create matches by team number without giving team slice - only a integer should be given as parameter.

e.g.:

func GenerateRoundRobinTournamentMatchesByNumber(numberTeams int) [][]string {}

Calculation of odd teams not correct (cachedTeam)

The generation of odd teams (5) is not correct - the way to use cachedTeam may be not the proper way to solve this rr tournament. Better would be adding a dummy team and remove it afterwards.

Used five teams and got following matches:

[
  [Team 1 Team 2] 
  [Team 3 Team 4] 
  [Team 3 Team 5] // double 3-5
  [Team 1 Team 5] 
  [Team 2 Team 3] 
  [Team 2 Team 4] // double 2-4
  [Team 1 Team 4] 
  [Team 5 Team 2] 
  [Team 5 Team 3] // double 3-5
  [Team 1 Team 3] 
  [Team 4 Team 5] 
  [Team 4 Team 2] // double 2-4
]

Instead of 12 the expected number of matches should be 10.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.