Sudoku: Difference between revisions

4 bytes removed ,  14 years ago
m
minor style/formatting
(sudoku solver in common lisp)
m (minor style/formatting)
Line 104:
(let* ((rmin (* 3 (floor row 3))) (rmax (+ rmin 3))
(cmin (* 3 (floor column 3))) (cmax (+ cmin 3)))
(do ((r rmin (1+ r))) ((eql= r rmax) neighbors)
(do ((c cmin (1+ c))) ((eql= c cmax))
(let ((x (aref grid r c)))
(unless (or (eq x '_) (= r row) (= c column))
Line 119:
(defun solve (grid &optional (row 0) (column 0))
(cond
((eql= row 9)
grid)
((eql= column 9)
(solve grid (1+ row) 0))
((numberpnot (eq '_ (aref grid row column)))
(solve grid row (1+ column)))
(t (dolist (choice (choices row column grid) (setf (aref grid row column) '_))
Anonymous user