In the eight queens puzzle, you need to place eight queens on a chessboard so that they aren’t attacking eachother. It has 92 solutions.

I implemented one method for solving the problem. It works for any *n*x*n* chessboard, but it’s not so fast with large boards.

- Compiled: Queens.jar
- Source: Queens.java

You can invoke this with `java -jar Queens.jar` for an 8×8 board, or `java -jar Queens.jar n` for an

*n*x

*n*board with

*n*queens.

It works by processing the board in vertical strips, first placing a queen in the top-right, and then attempting to place a queen in the second column at the first available space. Once it crosses the board like this, it has found a solution, but it goes through plenty of bad combinations first.

**Update:** online solution-viewer is now running to make that command-line output more useful.