On Fri, 21 Jan 2005, Danny Yoo wrote:

> > I mean:
> > if I enter (1,2,3,4,5) and I watn combinations of 3, I want to find:
> > (1,2,3) but then not (2,1,3), (3,1,2),...
> > (1,2,4)
> > (1,2,5)
> > (2,3,5)
> > (3,4,5)
>
>
> There is a clean recursive way to define this.

Hi Guillermo,


Gaaa; I screwed up slightly.  *grin*

I just wanted to clarify: the function that I'm sketching out is not
exactly the function that you're thinking of.  I'm doing more of a "give
me all the subsets of L" kind of thing.

But if you can understand how to get all the subsets, you should be able
to figure out how to get all the combinations of 'k' elements, because
they're really similar problems.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to