Introduction to OOP | Chapter 6: The Eight Queens Puzzle: | next | previous | audio | real | text |
Finding first solution, in pseudo-code:
function queen.findSolution -> boolean while neighbor.canAttack (row, column) do if not self.advance then return false; // found a solution return true; endWe ignore for the moment the question of what to do if you don't have a neighbor