How to resolve the algorithm Twelve statements step by step in the Yabasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Twelve statements step by step in the Yabasic programming language

Table of Contents

Problem Statement

This puzzle is borrowed from   math-frolic.blogspot.

Given the following twelve statements, which of them are true?

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.

Print out a table of near misses, that is, solutions that are contradicted by only a single statement.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Twelve statements step by step in the Yabasic programming language

Source code in the yabasic programming language

sub s1() return len(s$)=12 end sub
sub s2() local t, i : t=0 : for i=7 to 12 : t = t + (mid$(s$, i, 1) <> "0") : next : return t=3 end sub
sub s3() local t, i : t=0 : for i=2 to 12 step 2 : t = t + (mid$(s$, i, 1) <> "0") : next : return t=2 end sub
sub s4() return mid$(s$, 5, 1) = "0" or (mid$(s$, 6, 1) <> "0" and mid$(s$, 7, 1) <> "0") end sub
sub s5() return mid$(s$, 2, 1) = "0" and mid$(s$, 3, 1) = "0" and mid$(s$, 4, 1) = "0" end sub
sub s6() local t, i : t=0 : for i=1 to 12 step 2 : t = t + mid$(s$, i, 1) <> "0" : next : return t=4 end sub
sub s7() return mid$(s$, 2, 1) <> mid$(s$, 3, 1) end sub
sub s8() return mid$(s$, 7, 1) = "0" or (mid$(s$, 5, 1) <> "0" and mid$(s$, 6, 1) <> "0") end sub
sub s9() local t, i : t=0 : for i=1 to 6 : t = t + mid$(s$, i, 1) <> "0" : next : return t=3 end sub
sub s10() return mid$(s$, 11, 1) <> "0" and mid$(s$, 12, 1) <> "0" end sub
sub s11() local t, i : t=0 : for i=7 to 9 : t = t + mid$(s$, i, 1) <> "0" : next : return t=1 end sub
sub s12() local t, i : t=0 : for i=1 to 11 : t = t + mid$(s$, i, 1) <> "0" : next : return t=4 end sub
 
dim r$(12)

for b=1 to 12
    r$(b) = "s"+str$(b)
next
for i=0 to 2^12-1
    s$ = right$("000000000000" + bin$(i), 12)
    for b=1 to 12
        if execute(r$(b)) <> (mid$(s$, b, 1) <> "0") break
        if b=12 print s$
    next
next

  

You may also check:How to resolve the algorithm Abstract type step by step in the Aikido programming language
You may also check:How to resolve the algorithm Currency step by step in the REXX programming language
You may also check:How to resolve the algorithm Function composition step by step in the Slate programming language
You may also check:How to resolve the algorithm Random numbers step by step in the Picat programming language
You may also check:How to resolve the algorithm Vigenère cipher step by step in the Vedit macro language programming language