Re: Creating combinations from a group of sets

• To: mathgroup at smc.vnet.net
• Subject: [mg48713] Re: [mg48679] Creating combinations from a group of sets
• From: DrBob <drbob at bigfoot.com>
• Date: Fri, 11 Jun 2004 03:52:40 -0400 (EDT)
• References: <200406100643.CAA29466@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Does this do it?

oneFromEach[x_List] := Union[Union /@ Distribute[x, List]]

oneFromEach@{{1, 2, 3}, {4, 5}, {6}, {7, 8}}
{{1, 4, 6, 7}, {1, 4, 6, 8}, {1, 5, 6,
7}, {1, 5, 6, 8}, {2, 4, 6, 7}, {2, 4, 6, 8}, {2, 5, 6, 7}, {2, 5, 6, 8}, {
3, 4, 6, 7}, {3, 4, 6, 8}, {3, 5, 6, 7}, {3, 5, 6, 8}}

Bobby

On Thu, 10 Jun 2004 02:43:30 -0400 (EDT), Jeanette L Domber <Jeanette.L.Domber at aero.org> wrote:

>
> I have a group of sets:
>
> {1,2,3}
> {4,5}
> {6}
> {7,8}
>
> I wish to create all unique combinations of the sets that contain exactly one element from each set:
>
> {1,4,6,7}
> {1,5,6,7}
> {1,4,6,8}
> {1,5,6,8}
> {2,4,6,7}
> {2,5,6,7}
> etc.
>
> In all, there should be 12 combinations.
>
> If I use KSubsets giving it a list {1,2,3,4,5,6,7,8} to create combinations containing 4 elements, I get a list of 70 combinations, 58 of which are extraneous to my application.
>
> Does anyone know how to manipulate the functions in DiscreteMath`Combinatorica` to accomplish this efficiently?
>
> Thanks,
>     Jeanette
>
>

--
DrBob at bigfoot.com
www.eclecticdreams.net/index.html

```

• Prev by Date: Re: Energy content of a mathematical result.
• Next by Date: Re: Creating combinations from a group of sets
• Previous by thread: Re: Creating combinations from a group of sets
• Next by thread: Re: Creating combinations from a group of sets