Alright, you have an array[12][12], with starting values -1, so:
1 2 3
|
for(int i = 0; i < 12; i++) {
for(int j = 0; j < 12; j++) {
array[i][j] = -1; } }
|
Now, the array has to be filled with a greedy algorithm with the values 0 to 20. But in a way that the space between the values is less as possible, so for example when you only fill in 2 and 3 (it's an example, in the result should be the values 0-20):
-1 -1 -1 -1 2 3 -1 -1 ....
-1 -1 -1 -1 -1 -1 -1 -1 ....
-1 -1 -1 -1 -1 -1 -1 -1 ....
Now the space is 0 because there are 0 values between 2 and 3.
But when this is the situation:
-1 -1 -1 -1 -1 3 -1 -1 ....
-1 2 -1 -1 -1 -1 -1 -1 ....
-1 -1 -1 -1 -1 -1 -1 -1 ....
Now the space is 3 row-wise and 1 column-wise.
So the values should be as close to each other as possible.
The conditions:
2 values with the same last-digit (for example 0, 10 and 20) (or 1 and 11) can't be in the same column.