2
$\begingroup$

I have 98000 5-digit numbers, from 00001 to 98000. I need to distribute these 98000 numbers in 14000 5x5 matrices.

A matrix cell must contain only a digit from 0 to 9.

Each matrix must receive 7 numbers from the 98000: one number in each line and two in the diagonals.

All 98000 numbers must be distributed in all 14000 matrices, without repetition.

The distribution can't feel like it is sequential, it must appear "random".

Here is an example:

0 1 2 3 0
7 6 5 4 3
0 0 8 1 2
3 7 5 6 0
4 5 5 0 0

Line 1: Number 01230
Line 2: Number 76543
Line 3: Number 00812
Line 4: Number 37560
Line 5: Number 45500
Main Diagonal (from top-left to bottom-right): 06860
Secondary Diagonal (from bottom-left to top-right): 47840

Another example:

3 9 4 0 5
1 3 2 0 9
0 0 0 0 1
9 7 4 5 4
1 2 7 7 8

Line 1: Number 39405
Line 2: Number 13209
Line 3: Number 00001
Line 4: Number 97454
Line 5: Number 12778
Main Diagonal (from top-left to bottom-right): 33058
Secondary Diagonal (from bottom-left to top-right): 17005

Is it mathematically possible? I mean, one can distribute all 98000 numbers in 14000 matrices without repetition? If it is, how can I write an algorithm to do the distribution?

I tried to write a program in C# to do this task, but I couldn't find a good strategy to do it. My program always try to fill a number which was already filled.

Thanks in advance!

(Cross-post on stackoverflow)

$\endgroup$
5
  • $\begingroup$ Please link to all cross-posts of this questions, on stackexchange and elsewhere. It may avoid duplicate answers and increase inspiration from shared ideas. $\endgroup$ Commented Jun 17, 2014 at 17:42
  • $\begingroup$ FWIW, if this actually is possible to do (I don't really see any reason to believe otherwise), then a proof is almost surely going to take the form of an algorithm. $\endgroup$ Commented Jun 20, 2014 at 2:25
  • $\begingroup$ To reduce the search space you could introduce a symmetry breaking constraint: Matrix $m$ has to be smaller than matrix $m+1$. To compare two matrices, you could compare the smallest numbers contained in each of them. $\endgroup$ Commented Jun 21, 2014 at 10:55
  • $\begingroup$ @AxelKemper Thanks, but I don't see how comparing two matrices would help. $\endgroup$
    – wind39
    Commented Jun 21, 2014 at 21:29
  • 1
    $\begingroup$ Any solution to your problem can be transformed into other solutions by permuting the matrices. Therefore, by enforcing a sorted order of matrices, you can rule out many potential solutions and thus focus your search process. $\endgroup$ Commented Jun 21, 2014 at 21:49

0

You must log in to answer this question.