Skip to content

Programming Challenge: 8 Queens Problem

In my Algorithms class in my second semester of college (many, many eons ago), one of the project assignments was to write a program that would find all the solutions to the 8 Queens Problem.

What is the 8 Queens Problem?

If you are familiar with chess, you know that the queen is the most powerful piece on the board. It can move any number of squares in any direction in order to “kill” another piece. The 8 queens problem is defined like this:

“How many different solutions can you find for placing 8 queens on a chessboard so that they cannot kill another?”

Believe it or not, there are quite a few solutions. Back when I was in school, the language of choice for this class was Pascal and I wrote a Pascal program (on my Atari ST) that generated the solutions and printed them to the screen. I got an “A” on it.

A while ago I actually ported this old Pascal program (yes, I still have a copy, which you can download if you’re interested) to Xojo. I updated it a bit to add a graphical view of each of the solutions.

But before I tell you where you can find my updated Xojo solution, think about how you’d solve this using Xojo. Share your thoughts, ideas and projects on the forum.

My Xojo 8 Queens Problem project is included with the Xojo examples: Examples/Sample Applications/8Queens