Re: Combinations of two lists
- To: mathgroup at smc.vnet.net
- Subject: [mg41773] Re: Combinations of two lists
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Thu, 5 Jun 2003 07:31:20 -0400 (EDT)
- References: <bbkpb9$hef$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
For lists of length n, there will be n! rows and n columns (that is, n*n!
entries)
First@Outer[Transpose@{##}&,{list1},Permutations@list2,1]
Bob Hanlon
In article <bbkpb9$hef$1 at smc.vnet.net>, "John C. Erb, Ph.D."
<John_C_Erb at prodigy.net> wrote:
<<
Subject: Combinations of two lists
From: "John C. Erb, Ph.D." <John_C_Erb at prodigy.net>
To: mathgroup at smc.vnet.net
Date: Wed, 4 Jun 2003 12:40:09 +0000 (UTC)
Hello,
A simple example of what I would like to do is:
list1={x1,y1,z1}
list2={x2,y2,z2}
pair up the two lists to get all possible combinations
{x1,x2},{y1,y2},{z1,z2}
{x1,x2},{y1,z2},{z1,y2}
{x1,y2},{y1,x2},{z1,z2}
{x1,y2},{y1,z2},{z1,x2}
{x1,z2},{y1,x2},{z1,y2}
{x1,z2},{y1,y2},{z1,x2}
I would like a general way of telling how many ways
I can match up the two lists as shown above, and
optionally print out the combinations.
Thank you,
John C. Erb
email: John_C_Erb at prodigy.net
>><BR><BR>