Philip Jama

Eight Queens Riddle

A Chess-Based Algorithm Challenge

Project Overview

"A well known problem is to count the number of different ways in which eight queens can be placed on an 8×8 chess board without any two of them sharing the same row, column or diagonal."Martin Richards

Ignoring symmetries, 92 distinct solutions exist for an 8×8 board. Two solutions exist for smallest possible case, N=4, meaning 4 queens on a 4×4 board.

My solver code, written in C, uses bitwise operations to pack board solutions into a data structure composed of unsigned long integers. This implementation has a limit of N ≤ 8 (64-bits), but could be extended to work beyond the 8×8 case. Successful board arrangements are appended to a linked list and printed upon completion of the main recursion.

Project Details




May 2014




C, Recursion, Algorithms, Data Structures