Another Word For It Patrick Durusau on Topic Maps and Semantic Diversity

February 20, 2012

Solving the Queens Problem with Haskell

Filed under: Algorithms,Haskell — Patrick Durusau @ 8:35 pm

Solving the Queens Problem with Haskell

From the post:

The eight queens puzzle is a classic problem in algorithm design because it showcases the power of backtracking and recursion. The premise is simple: find a way to place 8 queens on an 8×8 board such that none of them are attacking each other, which means that no two queens can share the same row, column, or diagonal.

Sounds simple enough, but how to implement it? The most basic solution would be to brute force it: try every possible configuration, stopping when a valid one is found. Not very efficient, but hey, at least it’s easy to understand.

A good illustration of recursion and backtracking but also suggests that brute force isn’t the best option for authoring or manipulating topic maps.

A deep understanding of your data, relevant subjects, methods for identifying those subjects, etc., will be more useful than brute force.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress