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.




 
PROGRAM TWELVE_STMS
 
!$DYNAMIC
DIM PASS%[0],T%[0]
 
FUNCTION EOR(X,Y)
    EOR=(X AND NOT(Y)) OR (NOT(X) AND Y)
END FUNCTION
 
BEGIN
      NSTATEMENTS%=12
      !$DIM PASS%[NSTATEMENTS%],T%[NSTATEMENTS%]
 
      FOR TRY%=0 TO 2^NSTATEMENTS%-1 DO
 
        ! Postulate answer:
        FOR STMT%=1 TO 12 DO
          T%[STMT%]=(TRY% AND 2^(STMT%-1))<>0
        END FOR
 
        ! Test consistency:
        PASS%[1]=T%[1]=(NSTATEMENTS%=12)
        PASS%[2]=T%[2]=((T%[7]+T%[8]+T%[9]+T%[10]+T%[11]+T%[12])=-3)
        PASS%[3]=T%[3]=((T%[2]+T%[4]+T%[6]+T%[8]+T%[10]+T%[12])=-2)
        PASS%[4]=T%[4]=((NOT T%[5] OR (T%[6] AND T%[7])))
        PASS%[5]=T%[5]=(NOT T%[2] AND NOT T%[3] AND NOT T%[4])
        PASS%[6]=T%[6]=((T%[1]+T%[3]+T%[5]+T%[7]+T%[9]+T%[11])=-4)
        PASS%[7]=T%[7]=(EOR(T%[2],T%[3]))
        PASS%[8]=T%[8]=((NOT T%[7] OR (T%[5] AND T%[6])))
        PASS%[9]=T%[9]=((T%[1]+T%[2]+T%[3]+T%[4]+T%[5]+T%[6])=-3)
        PASS%[10]=T%[10]=(T%[11] AND T%[12])
        PASS%[11]=T%[11]=((T%[7]+T%[8]+T%[9])=-1)
        PASS%[12]=T%[12]=((T%[1]+T%[2]+T%[3]+T%[4]+T%[5]+T%[6]+T%[7]+T%[8]+T%[9]+T%[10]+T%[11])=-4)
 
        SUM=0
        FOR I%=1 TO 12 DO
           SUM=SUM+PASS%[I%]
        END FOR
 
        CASE SUM OF
          -11->
            PRINT("Near miss with statements ";)
            FOR STMT%=1 TO 12 DO
              IF T%[STMT%] THEN PRINT(STMT%;) END IF
              IF NOT PASS%[STMT%] THEN MISS%=STMT% END IF
            END FOR
            PRINT("true (failed ";MISS%;").")
          END ->
          -12->
            PRINT("Solution! with statements ";)
            FOR STMT%=1 TO 12 DO
              IF T%[STMT%] THEN PRINT(STMT%;) END IF
            END FOR
            PRINT("true.")
          END ->
        END CASE
 
      END FOR ! TRY%
END PROGRAM