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

2008-12-02 Thread Bertram Felgenhauer
Dan Doel wrote: On Monday 01 December 2008 1:39:13 pm Bertram Felgenhauer wrote: As one of the posters there points out, for n=100 the program doesn't actually backtrack if the 'loneliest neighbour' heuristic is used. Do any of our programs finish quickly for n=99? The Python one doesn't.

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

2008-12-02 Thread oleg
Yes, there is a solution for n=99 and for n=100 for that matter -- which can be found under one second. I only had to make a trivial modification to the previously posted code tour n k s b | k n*n = return b | otherwise = do next - (foldr mplus mzero).map return $ successors

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

2008-12-02 Thread ajb
G'day all. Quoting Bertram Felgenhauer [EMAIL PROTECTED]: successors n b = sortWith (length . succs) . succs [...] successors n b = sortWith (length . (succs =) . succs) . succs [...] successors n b = sortWith (length . (succs =) . (succs =) . succs) . succs [...] These improved

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

2008-12-01 Thread Bertram Felgenhauer
Don Stewart wrote: Lee Pike forwarded the following: Solving the Knight's Tour Puzzle In 60 Lines of Python http://developers.slashdot.org/article.pl?sid=08/11/30/1722203 Seems that perhaps (someone expert in) Haskell could do even better? Maybe even parallelize the

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

2008-12-01 Thread Dan Doel
On Monday 01 December 2008 1:39:13 pm Bertram Felgenhauer wrote: As one of the posters there points out, for n=100 the program doesn't actually backtrack if the 'loneliest neighbour' heuristic is used. Do any of our programs finish quickly for n=99? The Python one doesn't. Nothing I tried

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

2008-12-01 Thread wren ng thornton
Dan Doel wrote: On Monday 01 December 2008 1:39:13 pm Bertram Felgenhauer wrote: As one of the posters there points out, for n=100 the program doesn't actually backtrack if the 'loneliest neighbour' heuristic is used. Do any of our programs finish quickly for n=99? The Python one doesn't.

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

2008-11-30 Thread Don Stewart
Lee Pike forwarded the following: Solving the Knight's Tour Puzzle In 60 Lines of Python http://developers.slashdot.org/article.pl?sid=08/11/30/1722203 Seems that perhaps (someone expert in) Haskell could do even better? Maybe even parallelize the problem? :) So, team,

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

2008-11-30 Thread ajb
G'day all. Quoting Don Stewart [EMAIL PROTECTED]: So, team, anyone want to implement a Knight's Tour solver in a list monad/list comprehension one liner? These little puzzles are made for fast languages with backtracking monads I conjecture that any one-liner won't be efficient. Anyway,

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

2008-11-30 Thread Don Stewart
ajb: G'day all. Quoting Don Stewart [EMAIL PROTECTED]: So, team, anyone want to implement a Knight's Tour solver in a list monad/list comprehension one liner? These little puzzles are made for fast languages with backtracking monads I conjecture that any one-liner won't be

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

2008-11-30 Thread 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

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

2008-11-30 Thread Don Stewart
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

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

2008-11-30 Thread oleg
It seems the following pure functional (except for the final printout) version of the search has almost the same performance as the Dan Doel's latest version with the unboxed arrays and callCC. For the board of size 40, Dan Doel's version takes 0.047s on my computer; the version below takes