ASP 8 Queens solution
To find the solutions to the 8 queens puzzle. The puzzle asks "How can you place 8 Queens on a chess board so that no Queen can attack any other queen?"
Original Author: Richard Lindsay
Inputs
All the user has to input is the number of solutions they would like to see. (There are 92 possible ways to arrange 8Queens on a chess board so that no Queen can attack any other queen.
Assumptions
A recursive Algorithm is used. I copied my own VB code (also available on PlanetSourceCode) Only minor changes were required to run it as ASP. I generally do the "Hello World" exercise then I use the 8 Queens puzzle as my way of learning any new programming language. It forces me to learn most of the basic language structures (multi dimentional arrays, Functions, Display and/or printing, getting input etc.) By the time I finish the 8 Queens puzzle I usually feel pretty comfortable with a new language.
Returns
The result is a series of graphical displays that show how to arrange 8 Queens on a chess board so that no Queen can attack any other queen.
Side Affects
There are nearly 17,000,000 different ways to arrange 8 Queens on a chess board so if you ask to see all 92 solutions this code has to try them all. On a slower computer that can take 2 or 3 minutes since this is a script not compiled code.
Code
<%@ LANGUAGE=VBScript %>
<% Server.ScriptTimeOut=200 %>
<% If Request.Form("NumSolutions") = "" Then %>
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.