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.




var conditions = [
    { false },
    {|a| a.len == 13 },
    {|a| [a[7..12]].count(true) == 3 },
    {|a| [a[2..12 `by` 2]].count(true) == 2 },
    {|a| a[5] ? (a[6] && a[7]) : true },
    {|a| !a[2] && !a[3] && !a[4] },
    {|a| [a[1..11 `by` 2]].count(true) == 4 },
    {|a| a[2] == true^a[3] },
    {|a| a[7] ? (a[5] && a[6]) : true },
    {|a| [a[1..6]].count(true)  == 3 },
    {|a| [a[11,12]].count(true) == 2 },
    {|a| [a[7..9]].count(true)  == 1 },
    {|a| [a[1..11]].count(true) == 4 },
]
 
func miss(args) {
    1..12 -> grep {|i| conditions[i](args) != args[i] }
}
 
for k in (^(1<<12)) {
  var t  = ("0%012b" % k -> chars.map {|bit| bit == '1' })
  var no = miss(t)
  no.len == 0 && say "Solution: true statements are #{1..12->grep{t[_]}.join(' ')}"
  no.len == 1 && say "1 miss (#{no[0]}): true statements are #{1..12->grep{t[_]}.join(' ')}"
}