![]() |
Python
1.0
|
Non-continuous subsequences. More...
Functions | |
def | C (n, k) |
Calculates the k-combination of an integer. More... | |
def | nsubs (n) |
The number of k-combinations. More... | |
def | ncsub (seq) |
Enumerates all non-continuous subsequences for a given sequence. More... | |
def | main (argv=None) |
Non-continuous subsequences.
def _11_ncsub.C | ( | n, | |
k | |||
) |
Calculates the k-combination of an integer.
n | a given integer. |
k | an integer lesser than n. |
Referenced by nsubs().
def _11_ncsub.main | ( | argv = None | ) |
References _01d_dec2bin.input, and ncsub().
def _11_ncsub.ncsub | ( | seq | ) |
Enumerates all non-continuous subsequences for a given sequence.
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.
The idea behind this is to loop over the possible lengths of subsequence, finding all subsequences, then discarding those which are continuous.
Non Recursive version.
seq | a list of integers. |
References nsubs().
Referenced by main().