This puzzle is borrowed from   math-frolic.blogspot.



Given the following twelve statements, which of them are true?

 1.  This is a numbered list of twelve statements.
 2.  Exactly 3 of the last 6 statements are true.
 3.  Exactly 2 of the even-numbered statements are true.
 4.  If statement 5 is true, then statements 6 and 7 are both true.
 5.  The 3 preceding statements are all false.
 6.  Exactly 4 of the odd-numbered statements are true.
 7.  Either statement 2 or 3 is true, but not both.
 8.  If statement 7 is true, then 5 and 6 are both true.
 9.  Exactly 3 of the first 6 statements are true.
10.  The next two statements are both true.
11.  Exactly 1 of statements 7, 8 and 9 are true.
12.  Exactly 4 of the preceding statements are true.



Task

When you get tired of trying to figure it out in your head,
write a program to solve it, and print the correct answer or answers.



Extra credit

Print out a table of near misses, that is, solutions that are contradicted by only a single statement.




 
(defparameter *state* (make-list 12))
 
(defparameter *statements* '(t                                                    ; 1
                             (= (count-true '(7 8 9 10 11 12)) 3)                 ; 2
                             (= (count-true '(2 4 6 8 10 12)) 2)                  ; 3
                             (or (not (p 5)) (and (p 6) (p 7)))                   ; 4
                             (and (not (p 2)) (not (p 3)) (not (p 4)))            ; 5
                             (= (count-true '(1 3 5 7 9 11)) 4)                   ; 6
                             (or (and (p 2) (not (p 3))) (and (not (p 2)) (p 3))) ; 7
                             (or (not (p 7)) (and (p 5) (p 6)))                   ; 8
                             (= (count-true '(1 2 3 4 5 6)) 3)                    ; 9
                             (and (p 11) (p 12))                                  ;10
                             (= (count-true '(7 8 9)) 1)                          ;11
                             (= (count-true '(1 2 3 4 5 6 7 8 9 10 11)) 4)))      ;12
 
(defun start ()
  (loop while (not (equal *state* '(t t t t t t t t t t t t)))
        do (progn (let ((true-stats (check)))
		       (cond ((= true-stats 11) (result nil))
			     ((= true-stats 12) (result t))))
		  (new-state))))
 
(defun check ()
  (loop for el in *state*
        for stat in *statements*
        counting (eq el (eval stat)) into true-stats
        finally (return true-stats)))
 
(defun count-true (lst)
  (loop for i in lst
    counting (nth (- i 1) *state*) into total
    finally (return total)))
 
(defun p (n)
  (nth (- n 1) *state*))
 
(defun new-state ()
  (let ((contr t))
       (loop for i from 0 to 11
         do (progn (setf (nth i *state*) (not (eq (nth i *state*) contr)))
                   (setq contr (and contr (not (nth i *state*))))))))
 
(defun result (?)
  (format t "~:[Missed by one~;Solution:~] ~%~{~:[F~;T~] ~}~%" ? *state*))