Re: Matrix of possible combinations of N elements
- To: mathgroup at smc.vnet.net
- Subject: [mg31841] Re: Matrix of possible combinations of N elements
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 7 Dec 2001 05:55:59 -0500 (EST)
- References: <9ul2nj$6mv$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Per, How about: Permutations[{A,B,C,D}] {{A,B,C,D},{A,B,D,C},{A,C,B,D},{A,C,D,B},{A,D,B,C},{A,D,C,B},{B,A,C,D},{B,A, D, C},{B,C,A,D},{B,C,D,A},{B,D,A,C},{B,D,C,A},{C,A,B,D},{C,A,D,B},{C,B,A, D},{C,B,D,A},{C,D,A,B},{C,D,B,A},{D,A,B,C},{D,A,C,B},{D,B,A,C},{D,B,C, A},{D,C,A,B},{D,C,B,A}} -- 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 "Per Schjetne" <per.schjetne at dmhuset.no> wrote in message news:9ul2nj$6mv$1 at smc.vnet.net... > I have N elements and want to make a matrix of all possible combinations. > Example: > > A, B, C, D -> 4 elements > Combinations with 2 similar characters are not allowed (AAAA, AABB etc) > So that gives me 4*3*2*1=24 unique combinations > I have no problem writing all the combinations down, but I find it hard to > make a general function/algorithm in VB for generating matrix of any number > of elements. > > I know this is a common problem and instead of using days on this problem I > ask you gurus here! > > Per :-) > > > > > > > >