# Sorting numbergroups problem - Java-Games

This is a discussion on Sorting numbergroups problem - Java-Games ; Hi, I have 18 numbers. I pack those numbers into 153 number-pairs in a way so each of the numbers is once assigned to another number without the possibility of one pair appearing twice, or one number being assigned to ...

1. ## Sorting numbergroups problem

Hi,

I have 18 numbers. I pack those numbers into 153 number-pairs in a way so
each of the
numbers is once assigned to another number without the possibility of
one pair appearing twice, or one number being assigned to itself

18:17
18:16
....
18:1
17:16
17:15
....
17:1
16:15
....
....
2:1

Now I want to group those 153 pairs into 17 groups of 9 pairs each in a way
so each number appears
only once in a group an each group has exactly 9 pairs:

Example
Group 1:
1:2
3:4
5:6
7:8
9:10
11:12
13:14
15:16
17:18

Group 2:
1:3
2:4
5:8
6:7
9:12
12:10
13:15
17:16
15:18

Group 3:
....

I tried around and haven't found any sorting- or other algorithm which could
have done something like this...
Anybody with an idea?

3. ## Re: Sorting numbergroups problem

#include <stdio.h>

int main(void)
{
int i, j, t, n, g, player[1000];

n = 18; // can be any even number
for (g = 1; g < n; g++) {
printf("Group %d:\n", g);
for (i = 0, j = n - 1; i < j; i++, j--)
printf(" %d:%d\n", player[i], player[j]);
t = player[1];
for (j = 1; j < n - 1; j++)
player[j] = player[j+1];
player[j] = t;
}
return 0;
}