March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -1,14 +1,11 @@
|
|||
/*REXX program to solve the "Twelve Statement Puzzle". */
|
||||
/*REXX program solves the "Twelve Statement Puzzle". */
|
||||
q=12; @stmt=right('statement',20) /*number of statements in puzzle.*/
|
||||
m=0
|
||||
do pass=1 for 2 /*find the maximum number trues. */
|
||||
/*statement 1 is TRUE by fiat. */
|
||||
do e=0 for 2**(q-1); n='1'right(x2b(d2x(e)), q-1, 0)
|
||||
|
||||
do b=1 for q /*define the various bits. */
|
||||
@.b=substr(n,b,1) /*define a particular @ bit. */
|
||||
end /*b*/
|
||||
|
||||
m=0 /*[↓] statement 1 is TRUE by fiat*/
|
||||
do pass=1 for 2 /*find the maximum number trues. */
|
||||
do e=0 for 2**(q-1); n = '1'right(x2b(d2x(e)), q-1, 0)
|
||||
do b=1 for q /*define the various bits. */
|
||||
@.b=substr(n,b,1) /*define a particular @ bit. */
|
||||
end /*b*/
|
||||
if @.1 then if yeses(1,1) \==1 then iterate
|
||||
if @.2 then if yeses(7,12) \==3 then iterate
|
||||
if @.3 then if yeses(2,12,2) \==2 then iterate
|
||||
|
|
@ -24,14 +21,12 @@ m=0
|
|||
_=yeses(1,12)
|
||||
if pass==1 then do; m=max(m,_); iterate; end
|
||||
else if _\==m then iterate
|
||||
|
||||
do j=1 for q; _=substr(n,j,1)
|
||||
if _ then say @stmt right(j,2) " is " word('false true',1+_)
|
||||
end /*tell*/
|
||||
end /*e*/
|
||||
end /*pass*/
|
||||
do j=1 for q; _=substr(n,j,1)
|
||||
if _ then say @stmt right(j,2) " is " word('false true',1+_)
|
||||
end /*tell*/
|
||||
end /*e*/
|
||||
end /*pass*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*----------------------------------YESES subroutine--------------------*/
|
||||
yeses: parse arg L,H,B; #=0
|
||||
do i=L to H by word(B 1,1); #=#+@.i; end /*i*/
|
||||
return #
|
||||
/*──────────────────────────────────YESES subroutine────────────────────*/
|
||||
yeses: parse arg L,H,B; #=0; do i=L to H by word(B 1,1); #=#+@.i; end
|
||||
return #
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
/*REXX program to solve the "Twelve Statement Puzzle". */
|
||||
/*REXX program solves the "Twelve Statement Puzzle". */
|
||||
q=12; @stmt=right('statement',20) /*number of statements in puzzle.*/
|
||||
m=0
|
||||
do pass=1 for 2 /*find the maximum number trues. */
|
||||
/*statement 1 is TRUE by fiat. */
|
||||
do e=0 for 2**(q-1); n='1'right(x2b(d2x(e)), q-1, 0)
|
||||
|
||||
do b=1 for q /*define the various bits. */
|
||||
@.b=substr(n,b,1) /*define a particular @ bit. */
|
||||
end /*b*/
|
||||
|
||||
m=0 /*[↓] statement 1 is TRUE by fiat*/
|
||||
do pass=1 for 2 /*find the maximum number trues. */
|
||||
do e=0 for 2**(q-1); n = '1'right(x2b(d2x(e)), q-1, 0)
|
||||
do b=1 for q /*define the various bits. */
|
||||
@.b=substr(n,b,1) /*define a particular @ bit. */
|
||||
end /*b*/
|
||||
if @.1 then if \ @.1 then iterate
|
||||
if @.2 then if @.7+@.8+@.9+@.10+@.11+@.12 \==3 then iterate
|
||||
if @.3 then if @.2+@.4+@.6+@.8+@.10+@.12 \==2 then iterate
|
||||
|
|
@ -25,7 +22,6 @@ m=0
|
|||
_=_+@.12
|
||||
if pass==1 then do; m=max(m,_); iterate; end
|
||||
else if _\==m then iterate
|
||||
|
||||
do j=1 for q
|
||||
if @.j then say @stmt right(j,2) " is " word('false true',1+@.j)
|
||||
end /*j*/
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
/*REXX program to solve the "Twelve Statement Puzzle". */
|
||||
/*REXX program solves the "Twelve Statement Puzzle". */
|
||||
q=12; @stmt=right('statement',20) /*number of statements in puzzle.*/
|
||||
m=0
|
||||
do pass=1 for 2 /*find the maximum number trues. */
|
||||
/*statement 1 is TRUE by fiat. */
|
||||
do e=0 for 2**(q-1); n='1'right(x2b(d2x(e)), q-1, 0)
|
||||
m=0 /*[↓] statement 1 is TRUE by fiat*/
|
||||
do pass=1 for 2 /*find the maximum number trues. */
|
||||
do e=0 for 2**(q-1); n = '1'right(x2b(d2x(e)), q-1, 0)
|
||||
parse var n @1 2 @2 3 @3 4 @4 5 @5 6 @6 7 @7 8 @8 9 @9 10 @10 11 @11 12 @12
|
||||
/*¦¦¦ if @1 then if \ @1 then iterate ¦¦¦*/
|
||||
/*███ if @1 then if \ @1 then iterate ███*/
|
||||
if @2 then if @7+@8+@9+@10+@11+@12 \==3 then iterate
|
||||
if @3 then if @2+@4+@6+@8+@10+@12 \==2 then iterate
|
||||
if @4 then if @5 then if \(@6 & @7) then iterate
|
||||
|
|
@ -21,7 +20,6 @@ m=0
|
|||
_=_+@12
|
||||
if pass==1 then do; m=max(m,_); iterate; end
|
||||
else if _\==m then iterate
|
||||
|
||||
do j=1 for q; _=substr(n,j,1)
|
||||
if _ then say @stmt right(j,2) " is " word('false true',1+_)
|
||||
end /*j*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue