On Mon, May 01, 2006 at 03:42:53PM -0700, [EMAIL PROTECTED] wrote: > Not quite what I'm looking for. I would like a list of all partitions > with each partition having k or less elements, not just one instance.
def partition(S, k): parts = [] ct = 0 cp = [] for elem in S: if ct > k: parts.append(cp) cp = [] ct = 0 cp.append(elem) ct += 1 parts.append(cp) return parts > > If this was a take home exam problem, > > you should be ashamed of yourself! > > -- Aaron Watters - Michael -- mouse, n: a device for pointing at the xterm in which you want to type. -- Fortune Visit me on the Web: http://www.elehack.net -- http://mail.python.org/mailman/listinfo/python-list