The problem is that you can get to situations that are impossible to resolve. This is because you are generating random numbers as you go along without looking at the larger picture. Here is an example, if I use a 3 x 3 array just to get the idea across, your routine has completed the first row and has done the first and second numbers of the second row. The array currently looks like this (for example):
The problem is that we can not use the number 3 because it would not make the third column unique, however this is the only number we can use, otherwise the column will not be unique. Therefore this particular array will never be able to be completed. This proves that if your application were able to complete the array, there would be a definite pattern to it. This may not be a problem for you, however remember that it can never be completely random.
One way round this would be to use 2 array's, one with all the number predefined. This predefined array would look something like the one below:
Code:
1 2 3 4 5 6 7 8 9 10
2 3 4 5 6 7 8 9 10 1
3 4 5 6 7 8 9 10 1 2
4 5 6 7 8 9 10 1 2 3
5 6 7 8 9 10 1 2 3 4
6 7 8 9 10 1 2 3 4 5
7 8 9 10 1 2 3 4 5 6
8 9 10 1 2 3 4 5 6 7
9 10 1 2 3 4 5 6 7 8
10 1 2 3 4 5 6 7 8 9
This array works just as your application requires, however it will be the same every time and there is no element of randomness to it. To get round this you could randomly generate 2 numbers, essentially an x and a y co-ordinate. These co-ordinates would be used to build a new series in your second array, therefore if you chose the x and y co-ordinates of 1 and 1 respectively, your routine would start from column 1, row 1 and your second array would be identical to the first. However if you chose column 3, row 6 then the new array would start from 8:
Code:
` v
1 2 3 4 5 6 7 8 9 10
2 3 4 5 6 7 8 9 10 1
3 4 5 6 7 8 9 10 1 2
4 5 6 7 8 9 10 1 2 3
5 6 7 8 9 10 1 2 3 4
> 6 7 [8] 9 10 1 2 3 4 5
7 8 9 10 1 2 3 4 5 6
8 9 10 1 2 3 4 5 6 7
9 10 1 2 3 4 5 6 7 8
10 1 2 3 4 5 6 7 8 9
It would then use 9, 10, 1, 2, 3, 4 and 5 before starting from the beginning for the row again and use 6 and 7. The next row (row 2 in your new array) would start from column 3, row 7 of the predefined array (the column stays the same however the row increases by one). When the row has got to the last row (row 10) it would start from the first row and continue like this until it got to the starting row minus 1. Your second array would end up looking like this:
Code:
8 9 10 1 2 3 4 5 6 7
9 10 1 2 3 4 5 6 7 8
10 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
2 3 4 5 6 7 8 9 10 1
3 4 5 6 7 8 9 10 1 2
4 5 6 7 8 9 10 1 2 3
5 6 7 8 9 10 1 2 3 4
6 7 8 9 10 1 2 3 4 5
7 8 9 10 1 2 3 4 5 6
This way there are 100 different possible results for the second array. Bear in mind that there will always have to be a certain pattern to the results. If I can find the time I will try and work on some example algorithms for you.
The software required `Windows 95 or better', so I installed Linux.