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.




[([Int] -> Bool)] predicates
predicates [+]= st -> st.len == 12
predicates [+]= st -> sum(st[(len)-6 ..]) == 3
predicates [+]= st -> sum(st[(1..).step(2)]) == 2
predicates [+]= st -> I st[4] {(st[5] [&] st[6])} E 1
predicates [+]= st -> sum(st[1.<4]) == 0
predicates [+]= st -> sum(st[(0..).step(2)]) == 4
predicates [+]= st -> sum(st[1.<3]) == 1
predicates [+]= st -> I st[6] {(st[4] [&] st[5])} E 1
predicates [+]= st -> sum(st[0.<6]) == 3
predicates [+]= st -> (st[10] [&] st[11])
predicates [+]= st -> sum(st[6.<9]) == 1
predicates [+]= st -> sum(st[0.<11]) == 4
 
F to_str(b)
   R (0.<12).filter(i -> @b[i]).map(i -> i + 1).join(‘ ’)
 
print(‘Exact hits:’)
L(n) 0 .< (1 << 12)
   V bools = [0] * 12
   L(i) 12
      I n [&] (1 << (11 - i)) != 0
         bools[i] = 1
 
   L(predicate) predicates
      I Int(predicate(bools)) != bools[L.index]
         L.break
   L.was_no_break
      print(‘    ’to_str(bools))
 
print("\nNear misses:")
L(n) 0 .< (1 << 12)
   V bools = [0] * 12
   L(i) 12
      I n [&] (1 << (11 - i)) != 0
         bools[i] = 1
 
   V count = 0
   L(predicate) predicates
      I Int(predicate(bools)) == bools[L.index]
         count++
   I count == 11
      L(predicate) predicates
         V i = L.index
         I Int(predicate(bools)) != bools[i]
            print(f:‘    (Fails at statement {i + 1:2})  {to_str(bools)}’)
            L.break