On Thu, Jan 30, 2014 at 8:01 AM, Jim - FooBar(); <jimpil1...@gmail.com>wrote:

> Now, I am trying to combine his solver with the `random-puzzle` generator
> shown here ( http://jkkramer.com/sudoku.html).
>
[...]
> 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)
>

Well, first off, that isn't a sudoku.  It has a large number of solutions,
and a sudoku only has one solution.  I'm using my slightly modified version
of David's sudoku solver (https://gist.github.com/orb/8722569) but I
haven't changed anything core to the problem - it's just the version I have
laying around:

logic.sudoku> (def maybe-a-sudoku '(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))
#'logic.sudoku/maybe-a-sudoku

logic.sudoku> (pprint (partition 9 (first (solve maybe-a-sudoku))))
((1 3 5 4 7 2 9 8 6)
 (8 4 7 1 6 9 2 3 5)
 (6 9 2 5 3 8 1 4 7)
 (4 1 6 2 9 5 3 7 8)
 (2 5 3 6 8 7 4 9 1)
 (9 7 8 3 4 1 5 6 2)
 (7 6 1 9 5 4 8 2 3)
 (3 2 9 8 1 6 7 5 4)
 (5 8 4 7 2 3 6 1 9))
nil

Well, that's one, but clearly there's more.

logic.sudoku> (pprint (partition 9 (first (drop 100 (solve
maybe-a-sudoku)))))
((1 3 4 9 7 2 5 8 6)
 (8 5 7 6 3 1 2 4 9)
 (6 9 2 5 4 8 1 3 7)
 (4 1 5 2 6 7 3 9 8)
 (2 6 3 4 8 9 7 5 1)
 (9 7 8 3 1 5 4 6 2)
 (7 4 9 1 5 6 8 2 3)
 (5 2 1 8 9 3 6 7 4)
 (3 8 6 7 2 4 9 1 5))
nil

Lots more...

logic.sudoku> (pprint (partition 9 (first (drop 10000 (solve
maybe-a-sudoku)))))
((3 7 9 1 4 2 5 8 6)
 (8 1 5 7 6 3 2 4 9)
 (4 6 2 5 8 9 1 3 7)
 (1 4 6 2 7 5 3 9 8)
 (2 3 7 4 9 8 6 5 1)
 (9 5 8 3 1 6 4 7 2)
 (7 9 4 6 5 1 8 2 3)
 (5 2 1 8 3 7 9 6 4)
 (6 8 3 9 2 4 7 1 5))


I don't know how many solutions there are, but it seems like there are a
lot...  I think you are just generating all of them and it's taking a long
time.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to