On Nov 26, 12:15 am, [EMAIL PROTECTED] wrote:
bullockbefriending bard napisa³(a):
I'm not sure if my terminology is precise enough, but what I want to
do is:
Given an ordered sequence of n items, enumerate all its possible k-
segmentations.
This is *not* the same as enumerating the
I'm not sure if my terminology is precise enough, but what I want to
do is:
Given an ordered sequence of n items, enumerate all its possible k-
segmentations.
This is *not* the same as enumerating the k set partitions of the n
items because I am only interested in those set partitions which
bullockbefriending bard napisał(a):
I'm not sure if my terminology is precise enough, but what I want to
do is:
Given an ordered sequence of n items, enumerate all its possible k-
segmentations.
This is *not* the same as enumerating the k set partitions of the n
items because I am only
On Nov 25, 4:56 pm, bullockbefriending bard [EMAIL PROTECTED]
wrote:
I'm not sure if my terminology is precise enough, but what I want to
do is:
[snip problem description]
Structural Recursion not being my strong point, any ideas on how to go
about this would be much appreciated!
If you have
On Nov 25, 5:34 pm, Mark Dickinson [EMAIL PROTECTED] wrote:
If you have Python 2.6 available, itertools.combination might be
That should be itertools.combinations, of course.
The idea is that to give a partition of e.g., a 5-element list
into 3 nonempty pieces, all you have to do is say where
My version:
from itertools import combinations as xcombinations
from itertools import izip, islice
def xpairwise(iterable):
# docs and doctests removed
return izip(iterable, islice(iterable, 1, None))
def segmentations(seq, k):
for comb in xcombinations(range(1, len(seq)), k-1):
bullockbefriending bard [EMAIL PROTECTED] writes:
I'm not sure if my terminology is precise enough, but what I want to
do is:
Given an ordered sequence of n items, enumerate all its possible k-
segmentations.
This is *not* the same as enumerating the k set partitions of the n
items
bullockbefriending bard wrote:
I'm not sure if my terminology is precise enough, but what I want to
do is:
Given an ordered sequence of n items, enumerate all its possible k-
segmentations.
This is *not* the same as enumerating the k set partitions of the n
items because I am only interested