How program a particilar algorithm ?

Steve Holden sholden at holdenweb.com
Wed Nov 14 13:06:25 EST 2001


"Michel Bonnifait" <mbonnifait at wanadoo.fr> wrote in message
news:9sua59$3lh$1 at wanadoo.fr...
> Hello,
> I think my question is more on programming than specifically on
programming
> with Python.
> I want to generate all possible lists with elements from another one. For
> example, from a list like [1,2,3,4] i want to program an algorithm which
> will give this result
>
[[1,2],[1,3],[1,4],[1,2,3],[1,2,4],[1,3,4],[1,2,3,4],[2,3],[2,4],[2,3,4],[3,
> 4]]

Haven't you forgotten [1], [2], [3] and [4]?

> It's seems to me it should be a recursive programming answer but i can't
> find it.
> thanks in advance for your help !
>
Take a look at the following entry from the Python Programmer's Cookbook,
and good luck with your homework ;-)

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66465

when-i-was-a-student-there-was-no-google-to-ignore-ly y'rs  - steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list