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.
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
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
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
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
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.
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,
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,
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
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
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
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
12 matches
Mail list logo