Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
27
Task/Twelve-statements/Phix/twelve-statements.phix
Normal file
27
Task/Twelve-statements/Phix/twelve-statements.phix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
string s -- (eg "101101100010")
|
||||
integer t -- scratch
|
||||
|
||||
function s1() return length(s)=12 end function
|
||||
function s2() t=0 for i=7 to 12 do t+=s[i]='1' end for return t=3 end function
|
||||
function s3() t=0 for i=2 to 12 by 2 do t+=s[i]='1' end for return t=2 end function
|
||||
function s4() return s[5]='0' or (s[6]='1' and s[7]='1') end function
|
||||
function s5() return s[2]='0' and s[3]='0' and s[4]='0' end function
|
||||
function s6() t=0 for i=1 to 12 by 2 do t+=s[i]='1' end for return t=4 end function
|
||||
function s7() return s[2]!=s[3] end function
|
||||
function s8() return s[7]='0' or (s[5]='1' and s[6]='1') end function
|
||||
function s9() t=0 for i=1 to 6 do t+=s[i]='1' end for return t=3 end function
|
||||
function s10() return s[11]='1' and s[12]='1' end function
|
||||
function s11() t=0 for i=7 to 9 do t+=s[i]='1' end for return t=1 end function
|
||||
function s12() t=0 for i=1 to 11 do t+=s[i]='1' end for return t=4 end function
|
||||
|
||||
sequence r = repeat(0,12)
|
||||
for b=1 to 12 do
|
||||
r[b] = routine_id(sprintf("s%d",b))
|
||||
end for
|
||||
for i=0 to power(2,12)-1 do
|
||||
s = sprintf("%012b",i)
|
||||
for b=1 to 12 do
|
||||
if call_func(r[b],{})!=(s[b]='1') then exit end if
|
||||
if b=12 then ?s end if
|
||||
end for
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue