Skip to content

fjab76/worldcup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

worldcup

The idea for this project emerged during the recent Brazil Worldcup as an attempt to work out all the possible combinations of results for any given group. As it is known, the Groups stage of the worldcup consists in having groups formed by 4 teams which play each other once. The variety of results that happened got me thinking about how many combinations were possible.
The project has been developed using Java 8 and Groovy.

The initial efforts were fruitless until I came up with an appropriate representation of the potential results of a group, namely: fjab.worldcup.api.GroupResult. The use of this representation made it possible to generalise the problem to consider groups with any number of teams.

The method to calculate the number of groups is declared in the interface GroupResultCalculator and there are 2 different implementations: SolutionByConstruction and SolutionBySimulation.
SolutionByConstruction constructs all the possible combinations of results according to the definition of GroupResult.
SolutionBySimulation simulates the results of the different matches of a group to obtain all the possible combinations of results according to the definition of GroupResult. Repeating the simulation process 2,000 times is enough to get all the possible combinations for 4-team groups.

Finally, if you are curious about the number of result combinations that are possible for any given group, download the project and run it!!
There are 2 client classes with a main method, one for each algorithm: SolutionBySimulationClient and SolutionByConstructionClient.

mvn exec:java -Dexec.mainClass="fjab.worldcup.client.SolutionBySimulationClient" -Dexec.args="4 10000" mvn exec:java -Dexec.mainClass="fjab.worldcup.client.SolutionByConstructionClient" -Dexec.args="4"

or

sh target/bin/simulation 4 1000 sh target/bin/construction 4

About

Calculation of result combinations of Worldcup groups

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors