The properties of the flexdoku board
The image above shows a flexdoku board of size 9: - It has 9 rows numbered 0 to 8 - Each row contains 9 cells - It has 9 columns numbered 0 to 8 - Each row contains 9 cells - It has 81 (9 * 9) cells numbered 0 to 80
We can generalize to say that a board of size size
has:
size
rows numbered0
tosize-1
- Each row contains
size
cells size
columns numbered0
tosize-1
- Each column contains
size
cells size*size
cells numbered0
tosize*size - 1
Row numbers¶
Notice that the first cell in each row is a multiple of 9. In fact,
- For every cell number in row
0
, 9 goes into it0
times:- ex: 7 divided by 9 is
0
with remainder 7
- ex: 7 divided by 9 is
- For every cell number in row
1
, 9 goes into it1
time:- ex: 12 divided by 9 is
1
with remainder 3
- ex: 12 divided by 9 is
- For every cell in row
8
, 9 goes into it8
times:- ex: 73 divided by 9 is
8
with remainder 1
- ex: 73 divided by 9 is
Row values¶
As we noted, rows start on multiples of 9 (size
), and the indexes in the row increase by 1.
- Row
2
is indexes: 18 (2
*9
), 19, 20, 21, 22, 23, 24, 25, 26
Column numbers¶
From the previous examples, you may have noticed that the remainder was the same as the column number:
- Every cell number in column 1
can be divided by 9 with remainder 1
:
- ex: 73 divided by 9 is 8 with remainder 1
- Every cell number in column 3
can be divided by 9 with remainder 3
:
- ex: 12 divided by 9 is 1 with remainder 3
- Every cell number in column 7
can be divided by 9 with remainder 7
:
- ex: 7 divided by 9 is 0 with remainder 7
Column values¶
Each starts on the index equal to the column number (column 4
starts with index 4
) and each successive index in the column is found by adding 9 (size
) to the previous index.
- Column
2
is (2
, 11 (2
+9
), 20 (11 +9
), 29, 38, 47, 56, 65, 74
Block numbers¶
The reason a flexdoku board size must be a perfect square is that the board must be able to be divided into size
blocks which each contain size
cells. The rules of flexdoku say that in every row, every column, and every block, each of the size
markers (letters or digits) can only appear once.
For example, in a flexdoku board of size 9, we use the 9 letters: A
, B
, C
, D
, E
, F
, G
, H
, I
as markers. The letter A
may only appear once in every row, column and block.
A flexdoku board of size 9 contains the 9 blocks shown in the image above. They may be considered to be numbered 0
to 8
in 1 dimension, or to (0,0)
to (2,2)
in 2 dimensions. The discussion below relates to their positions in 2 dimensions: (blockrow, blockcol)
.
Block rows and columns¶
There are 3
block rows and block columns, each numbered 0
to 2
. Note that 3
is the square root of 9
, so we can generalize that there are sqrt(size)
block rows and block columns, each set numbered 0
to sqrt(size)-1
.
For size 9
:
- Block row
0
contains rows0
to2
- Block row
1
contains rows3
to5
- Block row
2
contains rows6
to8
- Block column
0
contains columns0
to2
- Block column
1
contains columns3
to5
- Block column
2
contains columns6
to8
Notice that dividing the row number by 3
(ignoring the remainder) gives us the block row number. The same is true for translating a column number into a block column number.
So for any cell index, we can know the block, for example:
- Cell
58
is in position(6, 4)
which is in block(2, 1)
because- 6 divided by 3 is
2
- 4 divided by 3 is
1
- 6 divided by 3 is
- Cell
16
is in position(1, 7)
which is in block(0, 2)
because- 1 divided by 3 is
0
- 7 divided by 3 is
2
- 1 divided by 3 is
Block values¶
A block starts at its top left index, notice that:
- The top left corners of the blocks in block row
0
fall in board row0
(0*3
). - The top left corners of the blocks in block row
1
fall in board row3
(1*3
). - The top left corners of the blocks in block row
2
fall in board row6
(2*3
).
Note the relationship to 3
, or the sqrt(size)
.
- The top left corners of the blocks in block column
0
start0
(0*3
) past the beginning of row0
. - The top left corners of the blocks in block column
1
start3
(1*3
) past the beginning of row1
. - The top left corners of the blocks in block column
2
start6
(2*3
) past the beginning of row2
.
Note the relationship to 3
, or the sqrt(size)
.
Some examples:
- Block
(0, 2)
starts at index(0 * 3 * 9) + (2 * 3)
(6
past the beginning of row0
, which is index0
) - Block
(2, 0)
starts at index(2 * 3 * 9) + (0 * 3)
(0
past the beginning of row6
, which is index54
) - Block
(1, 1)
starts at index(1 * 3 * 9) + (1 * 3)
(3
past the beginning of row3
, which is index27
)
To get the values in a block: get 3
consecutive values starting at the top left index, add 9
to the top left index and get 3
more values, add 9
again and get 3
more values.
Note that 9
is the size
and 3
is the sqrt(size)
.