N-Queens Combinatorial Problem

First see the problem solved using the List monad and a Scala for comprehension.

Then see the Scala program translated into Haskell, both using a do expression and using a List comprehension.

Understand how the Scala for comprehension is desugared, and what role the withFilter function plays.

Also understand how the Haskell do expression and List comprehension are desugared, and what role the guard function plays.

3 Likes

Hi all, here is part 2.

See how the guard function has migrated from MonadPlus to Alternative and learn something about the latter.

Learn how to write a Scala program that draws an N-Queens solution board using the Doodle graphics library.

See how to write the equivalent Haskell program using the Gloss graphics library.
learn how to use Monoid and Foldable to compose images both in Haskell and in Scala.

Hi all, here is part 3.

Learn how to write FP code that displays a graphical representation of all the numerous N-Queens solutions for N=4,5,6,7,8.

See how to neatly solve the problem by exploiting its self-similarity and using a divide and conquer approach.

Make light work of assembling multiple images into a whole, by exploiting Doodle’s facilities for combining images using a relative layout.

See relevant FP functions, like Foldable’s intercalate and intersperse, in action.