"Matt" <ma********@hotmail.com> wrote in message

news:cl****************@plethora.net...

I will be grateful if someone explians this part

colfree[c] = FALSE;

upfree[row+c] = FALSE;

downfree[row-c+7] = FALSE;

of the code below. I don't understand how this marks the downward and

upward diagonals. How does downfree[row-c+7] mark the diagonal?

There are 15 diagonals going from lower left to upper right and 15 diagonals

going from upper left to lower right. For any row and column, the formulas

'row+c' and 'row-c+7' computes the diagonal number for each direction as

shown below.

The 15 'upward' diagonals, in direction lower left to upper right corner,

are defined like this (in [row,col] format):

Diagonal 0 (row+col = 0): [0,0]

Diagonal 1 (row+col = 1): [0,1] [1,0]

Diagonal 2 (row+col = 2): [0,2] [1,1] [2,0]

Diagonal 3 (row+col = 3): [0,3] [1,2] [2,1] [3,0]

Diagonal 4 (row+col = 4): [0,4] [1,3] [2,2] [3,1] [4,0]

Diagonal 5 (row+col = 5): [0,5] [1,4] [2,3] [3,2] [4,1] [5,0]

Diagonal 6 (row+col = 6): [0,6] [1,5] [2,4] [3,3] [4,2] [5,1] [6,0]

Diagonal 7 (row+col = 7): [0,7] [1,6] [2,5] [3,4] [4,3] [5,2] [6,1]

[7,0]

Diagonal 8 (row+col = 8): [1,7] [2,6] [3,5] [4,4] [5,3] [6,2] [7,1]

Diagonal 9 (row+col = 9): [2,7] [3,6] [4,5] [5,4] [6,3] [7,2]

Diagonal 10 (row+col = 10): [3,7] [4,6] [5,5] [6,4] [7,3]

Diagonal 11 (row+col = 11): [4,7] [5,6] [6,5] [7,4]

Diagonal 12 (row+col = 12): [5,7] [6,6] [7,5]

Diagonal 13 (row+col = 13): [6,7] [7,6]

Diagonal 14 (row+col = 14): [7,7]

These are the 15 'downward' diagonals, in direction upper left to lowerer

right corner:

Diagonal 0 (row-col+7 = 0): [0,7]

Diagonal 1 (row-col+7 = 1): [0,6] [1,7]

Diagonal 2 (row-col+7 = 2): [0,5] [1,6] [2,7]

Diagonal 3 (row-col+7 = 3): [0,4] [1,5] [2,6] [3,7]

Diagonal 4 (row-col+7 = 4): [0,3] [1,4] [2,5] [3,6] [4,7]

Diagonal 5 (row-col+7 = 5): [0,2] [1,3] [2,4] [3,5] [4,6] [5,7]

Diagonal 6 (row-col+7 = 6): [0,1] [1,2] [2,3] [3,4] [4,5] [5,6] [6,7]

Diagonal 7 (row-col+7 = 7): [0,0] [1,1] [2,2] [3,3] [4,4] [5,5] [6,6]

[7,7]

Diagonal 8 (row-col+7 = 8): [1,0] [2,1] [3,2] [4,3] [5,4] [6,5] [7,6]

Diagonal 9 (row-col+7 = 9): [2,0] [3,1] [4,2] [5,3] [6,4] [7,5]

Diagonal 10 (row-col+7 = 10): [3,0] [4,1] [5,2] [6,3] [7,4]

Diagonal 11 (row-col+7 = 11): [4,0] [5,1] [6,2] [7,3]

Diagonal 12 (row-col+7 = 12): [5,0] [6,1] [7,2]

Diagonal 13 (row-col+7 = 13): [6,0] [7,1]

Diagonal 14 (row-col+7 = 14): [7,0]

Thanks for the program. I remember doing this a long time ago.

Dag

--

comp.lang.c.moderated - moderation address:

cl**@plethora.net