From: John Thingstad on
The Sat, 30 Jan 2010 13:34:10 +0100, Pascal J. Bourguignon wrote:

> John Thingstad <jpthing(a)online.no> writes:
>
>
> You're really asking for trouble.
>
>> (defparameter *sudoku-data*
>> '#2A((6 _ _ 2 _ 5)
>
> Not only do you use a literal data #2A(...) but what's more you're
> quoting it!
>
>> (setf (aref sudoky-board row col)
>
> and you expect this setf to work???
> Well, perhaps in your implementation, but not in CL.
>
> You should make a mutable copy somewhere!

Have you noticed that sudoku-board is NOT the same data structure as
*sudoku-data*? In fact all *sudoku-data* is used for is to allow a more
convenient way to enter sudoku data. When sudoku-board is created a whole
new array of list's is created and the values copied over. (ie. *sudoku-
board* is read only.)



--
John Thingstad
From: Pascal J. Bourguignon on
John Thingstad <jpthing(a)online.no> writes:

> The Sat, 30 Jan 2010 13:34:10 +0100, Pascal J. Bourguignon wrote:
>
>> John Thingstad <jpthing(a)online.no> writes:
>>
>>
>> You're really asking for trouble.
>>
>>> (defparameter *sudoku-data*
>>> '#2A((6 _ _ 2 _ 5)
>>
>> Not only do you use a literal data #2A(...) but what's more you're
>> quoting it!
>>
>>> (setf (aref sudoky-board row col)
>>
>> and you expect this setf to work???
>> Well, perhaps in your implementation, but not in CL.
>>
>> You should make a mutable copy somewhere!
>
> Have you noticed that sudoku-board is NOT the same data structure as
> *sudoku-data*? In fact all *sudoku-data* is used for is to allow a more
> convenient way to enter sudoku data. When sudoku-board is created a whole
> new array of list's is created and the values copied over. (ie. *sudoku-
> board* is read only.)

Oops, sorry, I missed it. I should not post when I'm not fully awake yet.

--
__Pascal Bourguignon__
From: w_a_x_man on
I don't know of anyone who works 6x6 Sudoku puzzles.
How long does your program take to solve this 9x9 one?


+-------+-------+-------+
| _ _ 6 | 9 _ _ | _ 7 _ |
| _ _ _ | _ 1 _ | _ _ 2 |
| 8 _ _ | _ _ _ | _ _ _ |
+-------+-------+-------+
| _ 2 _ | _ _ _ | _ _ 4 |
| _ _ _ | _ _ _ | _ _ 1 |
| _ _ 5 | _ _ 6 | _ _ _ |
+-------+-------+-------+
| _ _ _ | _ _ _ | _ 6 _ |
| _ _ _ | _ _ 2 | _ 5 _ |
| _ 1 _ | _ 4 3 | _ _ _ |
+-------+-------+-------+

From: John Thingstad on
The Sat, 30 Jan 2010 10:42:33 -0800, w_a_x_man wrote:

> I don't know of anyone who works 6x6 Sudoku puzzles. How long does your
> program take to solve this 9x9 one?
>
>
> +-------+-------+-------+
> | _ _ 6 | 9 _ _ | _ 7 _ |
> | _ _ _ | _ 1 _ | _ _ 2 |
> | 8 _ _ | _ _ _ | _ _ _ |
> +-------+-------+-------+
> | _ 2 _ | _ _ _ | _ _ 4 |
> | _ _ _ | _ _ _ | _ _ 1 |
> | _ _ 5 | _ _ 6 | _ _ _ |
> +-------+-------+-------+
> | _ _ _ | _ _ _ | _ 6 _ |
> | _ _ _ | _ _ 2 | _ 5 _ |
> | _ 1 _ | _ 4 3 | _ _ _ |
> +-------+-------+-------+

Not so well, yet. For one the valu 6 is harcoded, that needs to be
generalized. I foused on getting the constraints right. If there are
still several options left it would go into a infinate loop. So I would
need to add a backtracking search. Still that's not that difficult. Mabe
monday..

--
John Thingstad
From: Joshua Taylor on
John Thingstad wrote:
> The Fri, 29 Jan 2010 19:18:10 -0600, John Thingstad wrote:
>
>> Been learning unix system administration lately so I haven't had much
>> time to program. (Unless you call basic scripting programming.) Today I
>> took some time off so I made a rough prototype of a sudoku. To make this
>> elegant and general would require some more work but still a fun
>> diversion.
>>
>>
>> (defun set- (list1 list2)
>> (loop for element in list2 do
>> (when (member element list2)
>> (setf list1 (remove element list1))))
>> list1)
>>
>
> OOPS..
>
> (defun set- (list1 list2)
> (loop for element in list2 do
> (setf list1 (remove element list1)))
> list1)

Why not SET-DIFFERENCE [1]?

[1] http://www.lispworks.com/documentation/HyperSpec/Body/f_set_di.htm