Hi Team,
First, thank you for all your replies. I truly appreciate each and
everyone
of them!
Generally speaking I have problems explaining in writing an idea or what
I
intent to do.
But, let me try to explain what I would like to do.
I am trying to implement a sudoku algorithm.
Given an initial set of values which I represent as the following
example:
@ga = [
[0,0,0,0,1,9,0,4,0],
[0,0,4,8,0,0,6,0,0],
[7,5,0,0,0,0,0,0,2],
[0,9,0,1,0,2,0,0,4],
[0,0,0,0,0,3,0,0,0],
[5,0,0,4,0,6,0,3,0],
[8,0,0,0,0,0,0,7,3],
[0,0,6,0,0,8,4,0,0],
[0,1,0,2,9,0,0,0,0]
]
I use the above array to propagate the given values to a “master” array
which contains ALL the ORIGINAL valid and possible entries for a
location.
At the start all numbers from 1…9:
@aa = [
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789],
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789],
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789],
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789],
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789],
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789],
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789],
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789],
[123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789,123456789]
]
But I don’t want to propagate the zeroes (0) from the given array. I use
zeroes (0) for convenience only.
So, for instance, from the given array please notice that there is a one
(1)
at location @ga = [0][4].
Knowing the index of that non-zero value (1 in this case) I would then
use
the same index on the so called master array to place the 1.
I will then proceed to eliminate all the ones (1) from the same row and
column, since, as I am sure you know, the rule of sudoku only allows a
particular number once in a given row and column.
Well, that’s why I need the index, so I can a bit easier manipulate the
arrays and their contents.
Again, thank you for all your help.
Victor