Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-28 Thread Donald Bruce Stewart
chaddai.fouche: > For the translation of the above OCaml code, there is not much to do, > in fact it is mostly functional, and so easily translated in Haskell > code, note that I add a code to handle input of the form > "4.8.5.3..7..2.6.8.4..1...6.3.7.5..2.1.4...

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-27 Thread Daniel Fischer
Am Montag, 27. August 2007 10:09 schrieb manu: > Daniel Fischer's modifications to my original program lead to a 400 % > speed boost !!! > (It now runs in 22 seconds on my machine) > He avoided unecessary calls to 'length', uses Array instead of Map, > refactored 'search' function (details below) >

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-27 Thread manu
From: Daniel Fischer > Thought it was something like that. > Must check whether that beats Norvig's constraint propagation. it does ! on my machine : Jon Harrop's : 12.5 sec and Norvig's : 15 sec Manu ___ Haskell-Cafe mailing list Haskell-Cafe@hask

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-27 Thread Chaddaï Fouché
For the translation of the above OCaml code, there is not much to do, in fact it is mostly functional, and so easily translated in Haskell code, note that I add a code to handle input of the form "4.8.5.3..7..2.6.8.4..1...6.3.7.5..2.1.4..", to resolve it and

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-27 Thread Daniel Fischer
Am Montag, 27. August 2007 14:40 schrieb Jon Harrop: > > Probably not, but what's wrong with using arrays (here and in general)? > > Here I find arrays very natural, after all a grid has a fixed set of > > indices. And as they have a much faster lookup than maps (not to mention > > lists), what do

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-27 Thread Jon Harrop
On Monday 27 August 2007 11:54:20 you wrote: > Am Montag, 27. August 2007 11:24 schrieb Jon Harrop: > > You shouldn't have any problem writing a purely functional solver that is > > faster and much shorter than Norvig's Python without having to use > > arrays. > > Probably not, but what's wrong wit

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-27 Thread Daniel Fischer
Am Montag, 27. August 2007 11:24 schrieb Jon Harrop: > On Monday 27 August 2007 09:09:17 manu wrote: > > Daniel Fischer's modifications to my original program lead to a 400 % > > speed boost !!! > > (It now runs in 22 seconds on my machine) > > He avoided unecessary calls to 'length', uses Array in

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-27 Thread Jon Harrop
On Monday 27 August 2007 09:09:17 manu wrote: > Daniel Fischer's modifications to my original program lead to a 400 % > speed boost !!! > (It now runs in 22 seconds on my machine) > He avoided unecessary calls to 'length', uses Array instead of Map, > refactored 'search' function (details below) >

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-27 Thread manu
Daniel Fischer's modifications to my original program lead to a 400 % speed boost !!! (It now runs in 22 seconds on my machine) He avoided unecessary calls to 'length', uses Array instead of Map, refactored 'search' function (details below) I've put up his version on hpaste : http://hpaste.o

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread Yitzchak Gale
I wrote: >> Perhaps you would gain something if you used Data.Map.! >> instead of your "lookup". Manu wrote: > I'm not sure I understand, do you mean I should have use a strict Map > constructor ? > like : Map !key !value ? No, there is an operator in Data.Map called "!". > how can it replace th

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread manu
From: Malte Milatz <[EMAIL PROTECTED]> Subject: Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell Your program was wrapped by your mail client, so you may want to hpaste your program for easier digestion. here it is : http://hpaste.org/2452 Your profiling output suggest

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread Yitzchak Gale
Manu wrote: >> Should I introduce more strictness ? replace lists with more >> efficient data structures (ByteStrings, Arrays) ? Derek wrote: > Yes. Treating lists like arrays is always a recipe > for heartbreak. Here it costs very little - the lists are all short, mostly of length exactly 9. >

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread Yitzchak Gale
Hi Manu, You wrote: > After reading Peter Norvig's take on writing a Sudoku solver > (http://> norvig.com/sudoku.html) > I decided that I would port his program to Haskell, without changing > the algorithm, that'll make a nice exercise I thought > and should be fairly easy... Boy, was I wrong ! W

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread Malte Milatz
manu <[EMAIL PROTECTED]>: > After reading Peter Norvig's take on writing a Sudoku solver (http:// > norvig.com/sudoku.html) > I decided that I would port his program to Haskell Your program was wrapped by your mail client, so you may want to hpaste your program for easier digestion. > Being a be

Re: [Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread Derek Elkins
On Sun, 2007-08-26 at 14:50 +0200, manu wrote: > Hello, > > After reading Peter Norvig's take on writing a Sudoku solver (http:// > norvig.com/sudoku.html) > I decided that I would port his program to Haskell, without changing > the algorithm, that'll make a nice exercise I thought > and should

[Haskell-cafe] Norvig's Sudoku Solver in Haskell

2007-08-26 Thread manu
Hello, After reading Peter Norvig's take on writing a Sudoku solver (http:// norvig.com/sudoku.html) I decided that I would port his program to Haskell, without changing the algorithm, that'll make a nice exercise I thought and should be fairly easy... Boy, was I wrong ! Anyway, I eventually