Fork me on Github

Fork me on GitHub

Sep 19, 2012

The Zebra Puzzle implemented in FSharp

Yesterday I had the opportunity to show a solution at the Zurich FSharp Users Meetup Group.

I chose to show a small example of the Zebra Puzzle and an implementation of the solution to it in F#.

The implementation is rather basic as it uses simple integers to assign the attributes to the house. A more type safe implementation using a discriminated union for each attribute type is a good idea, more to follow on that in a later blog post with an improved example. Please find the code below.

Credits to Tomas Petricek, whose implementation of the permutations of a list I used from Stack Overflow.

The solution is shown below or under this link.