34 lines
656 B
Plaintext
34 lines
656 B
Plaintext
bool countonly = false
|
|
integer count = 0
|
|
|
|
procedure ncs(sequence rest, integer ri=0, sequence taken={}, bool contig=false, bool gap=false)
|
|
if ri>=length(rest) then
|
|
if contig then
|
|
if countonly then
|
|
count += 1
|
|
else
|
|
?taken
|
|
end if
|
|
end if
|
|
else
|
|
ri += 1
|
|
ncs(rest,ri,taken&rest[ri],gap,gap)
|
|
ncs(rest,ri,taken,contig,length(taken)!=0)
|
|
end if
|
|
end procedure
|
|
|
|
ncs({1,2,3})
|
|
?"==="
|
|
ncs({1,2,3,4})
|
|
?"==="
|
|
countonly = true
|
|
atom t0 = time()
|
|
sequence s = {}
|
|
for i=1 to 20 do
|
|
count = 0
|
|
ncs(tagset(i))
|
|
s = append(s,count)
|
|
end for
|
|
?time()-t0
|
|
?s
|