; (C) 2006 Markus Triska triska@metalevel.at ; Public domain code. ; A B C ; D E F G ; H I J K L ; M N O P ; Q R S ; "l", the "loop" macro (defmacro l (var code) `(loop for ,var from 1 to 19 do (when (not (aref used ,var)) (setf (aref used ,var) t) ,code (setf (aref used ,var) nil)))) ; "sc", the "set & check" macro, used when all other variables in the line ; are already assigned values (defmacro sc (var others code) `(let ((,var (- 38 ,@others))) (when (and (<= 1 ,var) (<= ,var 19) (not (aref used ,var))) (setf (aref used ,var) t) ,code (setf (aref used ,var) nil)))) (defun solve () (let ((used (make-array 20))) (l a (l b (sc c (a b) (l d (sc h (a d) (l e (l f (sc g (d e f) (sc l (c g) (l i (sc m (b e i) (sc q (h m) (l n (sc r (d i n) (sc s (q r) (sc p (s l) (sc j (q n c f) (sc o (a e j s) (sc k (r o g) (print (list a b c d e f g h i j k l m n o p q r s))))))))))))))))))))))) (solve) (quit)