Marc Rufer bio photo

Marc Rufer

Software engineer
@d-fens GmbH

Twitter Google+ LinkedIn Github Stackoverflow
RSS Feed

Swissunihockey key matcher

Marc Rufer 26 Mar 2015 swissunihockey sports Java

In my position as a participant of the committee of the floorball club Hornets Regio Moosseedorf Worblental I had to deal with a challenge. To overcome with the challenge I wrote a little program, which I want to present here.

Challenge

The floorball club got the game schedules for the U21 league and the 1st league for the season 2015/2016. In both schedules the teams of the corresponding weren’t filled in directly. For every game day there were combinations of keys, where every key will be replaced with a team. Now every club, which has a team in these leagues has to tell the swiss floorball association, which key should represent their team.

Below you can see an excerpt of such a game schedule

19.09.2015

Home Away
0 1
2 3
4 5
6 7

This means at September 19 the key 0 has home game against key 1.

For planning purposes the challenge was to figure out which key combinations would be best, so that the two teams playing in different leagues would have as many home games as possible at the same date.

Solution

First I tried to figure it out by taking a piece of paper and going through the combinations. After a few minutes I recognized that this approach is consuming too troublesome and time consuming, so I decided to write a java program, which will do the work for me.

The program I wrote consists of the following components

  • domain
    • League
    • MatchingResult (Matches per key combination)
  • KeyMatcher (Logic to calculate the matching results)
  • MatchingPrinter (Prints out the results to the console)

It took me several hours to write this program, but it avoids additional work in the future.

How to use

The following code snippet shows, how to use the swissunihockey key matcher

As you can see the two leagues have to be created by passing the amount of teams and a map containing home game keys per date. These leagues then have to be passed to the findMatchesForTwoLeagues method of a KeyMatcher instance. The matching result will be generated and can then be printed to the console by calling the static printResult-method of the MatchingPrinter.

The printed result looks as follows

The program is freely available on GitHub

comments powered by Disqus

Posts

HOWTO Access Azure File Share in PowerShell Script executed by a Scheduled Task BUG "Task Scheduler service is not available" Error, if specifying Network Connection Condition HOWTO Sync OneDrive on Server even if Windows User not logged in HOWTO Access Microsoft Access Database with PowerShell Get NetworkCredential from PSCredential splits Username into Username and Domain HOWTO Create LocalDB File (.mdf) manually in Visual Studio 2015 HOWTO Set Cookie Header on DefaultRequestHeaders of HttpClient HOWTO Set up PowerShell Remote Session Configuration HOWTO Analyze PowerShell Scripts with PSScriptAnalyzer HOWTO Sign PDF with SuisseID NoBrainer PUT/PATCH/MERGE with OData Service Client Apply Commit from one Repository to another GitHub Repository creation with PowerShell HOWTO Sign PowerShell Script with SuisseID Swissunihockey game schedule PDF generator HOWTO Maven Release on JetBrains TeamCity Limitations when running Activiti in H2 Embedded Mode HOWTO Pylint Integration in IntelliJ 14 HOWTO Install Windows 10 IoT Core on Raspberry PI 2 from a VM First steps with Dropwizard Allman code style for IntelliJ First steps with Flyway IntelliJ - Setup custom inspection profiles Configuration properties meta-data support in IntelliJ AMQP Integration with spring integration OCA Java SE 7 Programmer I Certification Guide Swissunihockey key matcher Swisscom SMS-API-Client Some hints concerning logging with Log4j IFTTT A brilliant service Run deltacloud on a VirtualBox-VM Project specific maven settings in IntelliJ AngularJS Javascript for beginners Liferay in Action