|
![](/i/fill.gif) |
On 31/05/2012 03:56 PM, scott wrote:
>> This in turn causes SEqual{} to function correctly.
>>
>> It's quite slow, but
>>
>> SEqual{List[1, 2, 3], List[3, 1, x]}
>>
>> does eventually yield x := 2.
>
> So for the first row in a sudoku I'd expect something like this:
>
> SEqual{List[1..9], List[3,a,b,c,1,d,e,f,8]}
>
> That should work, as both lists are the same length (so the 2nd list
> must contain the each of the elements 1-9 once).
>
> But I'm guessing it's going to be very slow, especially when you add in
> the other 26 SEqual statements all ANDed together...
>
> Shame, as I think it's a really neat way to write a solver.
When I removed the run time constraint, it took Logic Box about 22
seconds and 90 MB of RAM to come up with the first 10 solutions to the
predicate above. Of course, it's going to sit there and search for all
6! permutations of 6 items.
Think about what's happening under the covers: Logic Box is merely
searching through all possible combinations, trying to find one for
which all the constraints apply. I should imagine that for Sudoku, the
search space is /astronomical/, so it's likely to take a while. If it
takes 22 seconds to partially process one row, then processing 9 rows, 9
columns and 9 squares searching for a simultaneous solution to all of
them is going to take... a while.
I agree, however, that it would be very cool if this actually worked. :-D
Post a reply to this message
|
![](/i/fill.gif) |