Solve The Eight Queens Puzzle - Step 3

◀ Solve The Eight Queens Puzzle - Step 2▶ Solve The Eight Queens Puzzle - Step 4
Amazon Let’s run the 3rd step of the Four-Step Programming Model to solve the eight queen's puzzle!

Four Step Programming Model: Step 3
Now everything should be clear and you should be able to take over from here if you haven’t written the program yourself. Now we need to explore the program more deeply, making sure how variables are connected and so on.

Interrelation: There are several loops in the program and the index of each loop should not go out of bounds of the arrays that use it. In recur() pay special attention to the indices of the nested for loops because they may be used as parameter in recur().

Also pay attention to conflict() because you will need to perform vertical, horizontal, and diagonal testing on the board configuration to make sure no queens can attack another queen.

In this situation loops are used heavily and index-out-of-bound errors or logic errors are easy to make.
State: Once MAX is assigned a value it should not change through the program. The board configuration, board, will be used intensively in the program, so its values are changed constantly. If they are changed momentarily for testing purposes be sure to restore their previous values.

va should start out with nothing in it and accrue more and more unique solutions until it stores every possible solution.

Scope: As discussed, value in MAX should not change once assigned, so it deserves a constant, global scope. board and va can be either global or local, and I’d like to make them global so that they do not need to be passed around from function to function.

Let's look at the last step next!
◀ Solve The Eight Queens Puzzle - Step 2▶ Solve The Eight Queens Puzzle - Step 4

Questions? Let me know!