I have a problem that I have been thinking about, but I can’t really figure out how to solve it. I am writing software for my local sports club, which has an international tourney coming up soon. I would like to have the administration as automised as possible. I have done a great deal already, but now I’m struggling to get one last thing done.
Say, you have an array with 4 teams, namely team A, B, C and D. What I would like to do, is to create a new array, with all possible games. That isn’t so hard to do, but the difficulty lies in the fact that I would like to have some sort of sorting capability in it. The way I have it now, the games are created like this:
['A - B', 'A - C', 'A - D', 'B - C' , ...]
What I would like to have is something like this:
['A - B', 'C - D', 'A - C', 'B - D', 'A - D', ...]
Does anyone know how I could achieve this? any help would be greatly appreciated.
Sidenote: A – B = B – A, We don’t need a two-way competition (but I can program this bit myself if necessary).
I have found the solution to my problem.
it is shown below 🙂