Hi all,
I think we are all familiar with the wonderful core.logic
implementation of a sudoku solver by David Nolen. Now, I am trying
to combine his solver with the `random-puzzle` generator shown here
(
http://jkkramer.com/sudoku.html).
I have made the necessary changes (to deal with seqs of numbers
rather than strings and to return 0 instead `.` for empty squares)
but doing `(solve (random-puzzle))` eats up memory without returning
anything, whereas trying out some of the ready made puzzles shown as
examples on the above link works!
I suspected a different board representation between the 2 projects
but then I noticed that the ready-made examples work in both
implementations so it can't be that...both implementations seem to
accept a 1D seq of either strings or numbers.
any clues? I'd like to be able to generate random-puzzles that can
be passed to the core.logic solver. Currently `(random-puzzle)`
returns something like this which at first glance seems compatible
with David's solver:
user=> (random-puzzle 17)
(0 0 0 0 0 2 0 0 6 8 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 7 0 0 0 0 0 0 3
0 8 2 0 0 0 0 0 0 0 1 0 0 0 3 0 0 0 0 2 7 0 0 0 5 0 8 0 3 0 2 0 0 0
0 0 0 4 0 0 0 0 0 0 0 0 0)
user=> (count (filter (complement zero?) *1))
17
has anyone looked at both projects?
thanks in advance :)
Jim