Introduction to OOP | Chapter 6: The Eight Queens Puzzle: | next | previous | audio | real | text |
function canAttack(r, c) if r = row then return true cd := column - c; if (row + cd = r) or (row - cd = r) then return true; return neighbor.canAttack(r, c) endFor a diagonal, the difference in row must equal the difference in columns.