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.




/*REXX program solves the  "Twelve Statement Puzzle".                                   */
q=12;      @stmt=right('statement',20)           /*number of statements in the puzzle.  */
m=0                                              /*[↓]  statement one is  TRUE  by fiat.*/
      do pass=1  for 2                           /*find the maximum number of  "trues". */
        do e=0   for 2**(q-1);    n = '1'right( x2b( d2x( e ) ),  q-1,  0)
              do b=1  for q                      /*define various bits in the number  Q.*/
              @.b=substr(n, b, 1)                /*define a particular  @  bit  (in  Q).*/
              end   /*b*/
        if @.1  then if yeses(1,  1)                        \==1  then iterate
        if @.2  then if yeses(7, 12)                        \==3  then iterate
        if @.3  then if yeses(2, 12,2)                      \==2  then iterate
        if @.4  then if yeses(5,  5)   then  if yeses(6, 7) \==2  then iterate
        if @.5  then if yeses(2,  4)                        \==0  then iterate
        if @.6  then if yeses(1, 12,2)                      \==4  then iterate
        if @.7  then if yeses(2,  3)                        \==1  then iterate
        if @.8  then if yeses(7,  7)   then  if yeses(5,6)  \==2  then iterate
        if @.9  then if yeses(1,  6)                        \==3  then iterate
        if @.10 then if yeses(11,12)                        \==2  then iterate
        if @.11 then if yeses(7,  9)                        \==1  then iterate
        if @.12 then if yeses(1, 11)                        \==4  then iterate
        g=yeses(1, 12)
        if pass==1  then do;  m=max(m,g);  iterate;  end
                    else if g\==m     then iterate
            do j=1  for q;             z=substr(n, j, 1)
            if z  then  say @stmt right(j, 2)    " is "    word('false true', 1 + z)
            end   /*tell*/
        end       /*e*/
      end         /*pass*/
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
yeses: parse arg L,H,B;  #=0;    do i=L  to H  by word(B 1, 1);  #=#+@.i;  end;   return #