RosettaCodeData/Task/Non-continuous-subsequences/00DESCRIPTION

20 lines
989 B
Plaintext

Consider some sequence of elements. (It differs from a mere set of elements by having an ordering among members.)
A ''subsequence'' contains some subset of the elements of this sequence, in the same order.
A ''continuous'' subsequence is one in which no elements are missing between the first and last elements of the subsequence.
Note: Subsequences are defined ''structurally'', not by their contents.
So a sequence ''a,b,c,d'' will always have the same subsequences and continuous subsequences, no matter which values are substituted; it may even be the same value.
'''Task''': Find all non-continuous subsequences for a given sequence.
Example: For the sequence   ''1,2,3,4'',   there are five non-continuous subsequences, namely:
::::*   ''1,3''
::::*   ''1,4''
::::*   ''2,4''
::::*   ''1,3,4''
::::*   ''1,2,4''
'''Goal''': There are different ways to calculate those subsequences. Demonstrate algorithm(s) that are natural for the language.