[Haskell-cafe] The Knight's Tour: solutions please

Don Stewart dons at galois.com
Sun Nov 30 21:14:28 EST 2008


dan.doel:
> Here's a clean-up of my code (it even fits within the line-length limit of my 
> mail client :)). Note that it's pretty much exactly the Python algorithm. When 
> the Python program finds a solution, it prints the board and exits. Since 
> that's evil IO type stuff, we noble functional folk instead set up an exit 
> continuation using callCC, and call it when we find a solution. :)
> 
> I haven't bothered testing it against the Python version, but the backtracking 
> solution I wrote with the Logic monad (and Data.Map) took around 50% more time 
> than this.

I've created a wiki page,

    http://haskell.org/haskellwiki/The_Knights_Tour

I note the LogicT version is the shortest so far.

-- Don


More information about the Haskell-Cafe mailing list