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.




function s1(string s) return length(s)=12 end function
function s2(string s) return sum(sq_eq(s[7..12],'1'))=3 end function
function s3(string s) return sum(sq_eq(extract(s,tagset(12,2,2)),'1'))=2 end function
function s4(string s) return s[5]='0' or s[6..7]="11" end function
function s5(string s) return s[2..4]="000" end function
function s6(string s) return sum(sq_eq(extract(s,tagset(12,1,2)),'1'))=4 end function
function s7(string s) return s[2]!=s[3] end function
function s8(string s) return s[7]='0' or s[5..6]="11" end function
function s9(string s) return sum(sq_eq(s[1..6],'1'))=3 end function
function s10(string s) return s[11..12]="11" end function
function s11(string s) return sum(sq_eq(s[7..9],'1'))=1 end function
function s12(string s) return sum(sq_eq(s[1..11],'1'))=4 end function
 
sequence rtn = {s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12}
string misses = "\n"
for i=0 to power(2,12)-1 do
    string s = sprintf("%012b",i)
    sequence res = find_all('1',s)
    integer t = 0, pass, fail
    for b=1 to 12 do
        pass = call_func(rtn[b],{s})=(s[b]='1')
        if not pass then fail = b end if
        t += pass
        if b=12 and t=12 then printf(1,"Solution: %v\n",{res}) end if
    end for
    if t=11 then
        misses &= sprintf("Near miss: %v, fail on %d\n",{res,fail})
    end if
end for
puts(1,misses)
