Created
September 26, 2015 23:48
-
-
Save Iron-Ham/68f0a31cd18c0546721d to your computer and use it in GitHub Desktop.
a description of the logic to calculate 8-queens solutions recursively.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ways to arrange 8 queens on an 8x8 board = | |
ways to arrange 8 queens on an 8x8 board with queen at (7,0) | |
ways to arrange 8 queens on an 8x8 board with queen at (7, 1) | |
ways to ... with queen at (7, 2) | |
ways to ... with queen at (7, 3) | |
ways to ... with queen at (7, 4) | |
ways to ... with queen at (7, 5) | |
ways to ... with queen at (7, 6) | |
ways to ... with queen at (7, 7) | |
= 8 branches | |
Each one of these "branches" can be computed by calculating: | |
ways to ... with queen at (7, 2) = | |
ways to ... with queen at (7, 2) and (6, 0) | |
ways to ... with queen at (7, 2) and (6, 4) | |
ways to ... with queen at (7, 2) and (6, 5) | |
ways to ... with queen at (7, 2) and (6, 6) | |
ways to ... with queen at (7, 2) and (6, 7) | |
= 5 branches | |
(We don't need to check the other 3 possibilities, because it would violate the | |
solution constraints) | |
etc... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment