0
votes

I am struggling with an algorithm that solves the PE Problem #149. This algorithm, already fully programmed, can be found here.

Within this particular algorithm, I do not understand why the programmer has written code for a diagonal 2 direction and anti-diagonal 2 direction. Is this necessary from a programming point of view? I can't think of any mathematical reason!

Why does it not suffice to look only in the (1) horizontal, (2) vertical, (3) diagonal and (4) anti-diagonal directions?? We are dealing with a nxn matrix (square) in the end...

Let me know your thoughts on this. In the meanwhile I'm waiting for reply from the author.

1

1 Answers

0
votes

Yes, it is just an implementation detail. It still looks only in 4 directions. It is necessary because a diagonal can either end in the last row and some column or in the last column and some row.