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.




import system'routines;
import extensions;
import extensions'text;
 
extension op
{
    printSolution(bits)
        = self.zipBy(bits,
            (s,b => s.iif("T","F") + (s.xor:b).iif("* ","  "))).summarize(new StringWriter());
 
    toBit()
        = self.iif(1,0);
}
 
puzzle = new Func1[]
{
    (bits => bits.Length == 12),
 
    (bits => bits.last(6).selectBy:(x => x.toBit()).summarize() == 3 ),
 
    (bits => bits.zipBy(new Range(1, 12), 
                        (x,i => (i.toInt().isEven()).and:x.toBit())).summarize() == 2 ),
 
    (bits => bits[4].iif(bits[5] && bits[6],true) ),
 
    (bits => ((bits[1] || bits[2]) || bits[3]).Inverted ),
 
    (bits => bits.zipBy(new Range(1, 12), 
                        (x,i => (i.toInt().isOdd()).and:x.toBit() )).summarize() == 4 ),
 
    (bits => bits[1].xor(bits[2]) ),
 
    (bits => bits[6].iif(bits[5] && bits[4],true) ),
 
    (bits => bits.top(6).selectBy:(x => x.toBit() ).summarize() == 3 ),
 
    (bits => bits[10] && bits[11] ),
 
    (bits => (bits[6].toBit() + bits[7].toBit() + bits[8].toBit())==1 ),
 
    (bits => bits.top(11).selectBy:(x => x.toBit()).summarize() == 4 )
};
 
public program()
{
    console.writeLine();
 
    for(int n := 0, n < 2.power(12), n += 1)
    {
        var bits := BitArray32.load(n).top(12).toArray();
        var results := puzzle.selectBy:(r => r(bits)).toArray();
 
        var counts := bits.zipBy(results, (b,r => b.xor:r.toBit() )).summarize();
 
        counts =>
            0  { console.printLine("Total hit :",results.printSolution:bits) }
            1  { console.printLine("Near miss :",results.printSolution:bits) }
            12 { console.printLine("Total miss:",results.printSolution:bits) };
    };
 
    console.readChar()
}