Re: Help on Partitions, Again!!!

• To: mathgroup at smc.vnet.net
• Subject: [mg24651] Re: Help on Partitions, Again!!!
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Mon, 31 Jul 2000 09:23:21 -0400 (EDT)
• References: <8lt1mt\$2m2@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```We can use the Combinatorica function KSubsets (but a custom function should
be quicker)

<< DiscreteMath`Combinatorica`

lst = {A, B, C, D, E, F};

KSubsets[lst, 3]

{#, Complement[lst, #]} & /@ %

Sort /@ %

Union[%]

{{{A, B, C}, {D, E, F}}, {{A, B, D}, {C, E, F}},
{{A, B, E}, {C, D, F}}, {{A, B, F}, {C, D, E}},
{{A, C, D}, {B, E, F}}, {{A, C, E}, {B, D, F}},
{{A, C, F}, {B, D, E}}, {{A, D, E}, {B, C, F}},
{{A, D, F}, {B, C, E}}, {{A, E, F}, {B, C, D}}}

Length[%]

10

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Jose Prado de Melo" <jpmelo at iconet.com.br> wrote in message
news:8lt1mt\$2m2 at smc.vnet.net...
>
>
> Hello, MathGroup
> First of all, thanks for your attention.
> To be more specific:
> It's not too dificult to calculate the solution of the problem:
> How many ways, can the set {A,B,C,D,E,F} be separeted into two parts
> with three elements in each?
>  Answer:   x = 6!/(2!.3!.3!) = 10
>  I'm looking for a function to generate all the partitions using
> Mathematica 3.0 .
> I'm not sure, but I think the package Combinatorica doesn't have a
> function to do this.
> For example, I'm trying to think up a function f  like this one:
>
> In[ ] = f [ {A,B,C,D,E,F},{3,3}]
> Out [ ] = { { {A,B,C},{D,E,F} }, { {
> A,B,F},{C,D,E}},...................} and so on.
> In [ ] = Length[%]
> Out [ ] = 10
>