(defun remove-nth (data n) (cond ((= 0 n) (cdr data)) (t (cons (car data) (remove-nth (cdr data) (1- n)))))) (defun remove-block (data row col) (mapcar #'(lambda (x) (remove-nth x col)) (remove-nth data row))) (defun zero-nth (data n) (cond ((= 0 n) (cons 0 (cdr data))) (t (cons (car data) (zero-nth (cdr data) (1- n)))))) (defun zero-block (data row col) (cond ((= 0 row) (cons (zero-nth (car data) col) (cdr data))) (t (cons (car data) (zero-block (cdr data) (1- row) col))))) (defun empty (data) (not (car data))) (defun rook (data) (cond ((empty data) (list 1)) (t (let* ((coords (find-2d data)) (row (car coords)) (col (cadr coords))) (cond (coords (sum-poly (rook (zero-block data row col)) (cons 0 (rook (remove-block data row col))))) (t (list 1))))))) (defun find-1d-n (data n) (cond ((empty data) nil) ((= 0 (car data)) (find-1d-n (cdr data) (1+ n))) (t n))) (defun find-1d (data) (find-1d-n data 0)) (defun find-2d-n (data row) (let ((found-col (find-1d (car data)))) (cond ((empty data) nil) (found-col (list row found-col)) (t (find-2d-n (cdr data) (1+ row)))))) (defun find-2d (data) (find-2d-n data 0)) (defun sum-poly (p1 p2) (cond ((and (empty p1) (empty p2)) nil) (t (cons (+ (cond ((empty p1) 0) (t (car p1))) (cond ((empty p2) 0) (t (car p2)))) (sum-poly (cdr p1) (cdr p2)))))) (rook '((1 1) (1 0)))