(this question was modified after initial answers)
For a sequence
x = {6,4,2,4,2,4,6}
y = Subsequences[x]
gives the list of all subsequences, I would like to find the subset m of these subsequences which have distinct values, where each subsequence is composed of consecutive values in x. Or at most z repeat values.
subset m of subsequences of x with distinct values:
6
6,4
6,4,2
4
4,2
2
2,4
2,4,6
4,6
How can I remove the subsequences with duplicate values?
Is it possible to give the starting list position in x for each of the m?
z = 1; Select[EqualTo[z]@*Max@*Counts]@y
? $\endgroup$4,6
be part of your subsequence? If so then just addDeleteDuplicates
to @kglr 's code ieDeleteDuplicates@*Select[EqualTo[z]@*Max@*Counts]@y
$\endgroup$z=2
is this the desired output ?{{6}, {6, 4}, {6, 4, 2}, {6, 4, 2, 4}, {6, 4, 2, 4, 2}, {4}, {4, 2}, {4, 2, 4}, {4, 2, 4, 2}, {2}, {2, 4}, {2, 4, 2}, {2, 4, 2, 4}, {2, 4, 2, 4, 6}, {4, 2, 4, 6}, {2, 4, 6}, {4, 6}}
$\endgroup$