This program solves the famous 8-Queens Problem and will print a random solution out of the total 92 solutions on an 8x8 formatted chessboard. The 8-Queens Problem is a classic chess problem where the main goal is to place eight queens on a standard 8x8 chessboard in a way that no queen threatenes another. This means that no two queens can be on the same row, column, or diagonal. It uses a backtracking algorithm to place the queens on the board and will check that no other queen is in the same row or diagonal.
The code solves and stores all possible solutions to the problem by calling the 'solve_and_store()' function. It then randomly chooses one of the solutions by creating a random number and then compares itself to the total number of solution.
The program then prints out one random solution out of the 92 solutions and generates an image based on the solution using cairo graphics and save it on your desktop for
you to view. To verify the printed board use the following website: http://www.datagenetics.com/blog/august42012/index.html
This program might ask you to install some librarires so if it does just run the following command:
sudo apt-get install libcairo2-dev libcairo-gobject2
To see if it is installed:
dpkg -l | grep -E 'libcairo2-dev|libcairo-gobject2'
Make sure you are running it on a working version of ubuntu. To compile it run this command on terminal:
gcc -o queens queens.c $(pkg-config --cflags --libs cairo)
If everything is done correctly then it will compile and you can run the program using:
./queens


