Non-continuous subsequences: Difference between revisions

m
(Actually does the modification.)
Line 1,689:
</pre >
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
We make all the subsets then filter out the continuous ones:
 
<lang Mathematica>GoodBad[i_List]:=Not[MatchQ[Differences[i],{1..}|{}]]
n=5
Select[Subsets[Range[n]],GoodBad]</lang>
{{out}}
 
<lang Mathematicapre> {{1,3},{1,4},{1,5},{2,4},{2,5},{3,5},{1,2,4},{1,2,5},{1,3,4},{1,3,5},{1,4,5},{2,3,5},{2,4,5},{1,2,3,5},{1,2,4,5},{1,3,4,5}}</langpre>
gives back:
 
<lang Mathematica> {{1,3},{1,4},{1,5},{2,4},{2,5},{3,5},{1,2,4},{1,2,5},{1,3,4},{1,3,5},{1,4,5},{2,3,5},{2,4,5},{1,2,3,5},{1,2,4,5},{1,3,4,5}}</lang>
 
=={{header|Nim}}==
1,111

edits