Re: There must be a better way.
- To: mathgroup at smc.vnet.net
- Subject: [mg111968] Re: There must be a better way.
- From: Murta <rodrigomurtax at gmail.com>
- Date: Sun, 22 Aug 2010 08:11:02 -0400 (EDT)
- References: <i4j40i$qrg$1@smc.vnet.net> <i4lntd$7it$1@smc.vnet.net>
On Aug 20, 8:11 am, Ray Koopman <koop... at sfu.ca> wrote: > On Aug 19, 4:19 am, "S. B. Gray" <stev... at ROADRUNNER.COM> wrote: > > > > > > > pts = 5; > > angx = Flatten[ > > Table[Join[{j}, > > Subsets[Cases[Range[pts],Except[j]],{2}][[i]]],{j, > > pts},{i,(pts-1)(pts-2)/2}],1] > > > which if pts=4 gives > > > {{1, 2, 3}, {1, 2, 4}, {1, 3, 4}, > > {2, 1, 3}, {2, 1, 4}, {2, 3, 4}, > > {3, 1, 2}, {3, 1, 4}, {3, 2, 4}, > > {4, 1, 2}, {4, 1, 3}, {4, 2, 3}} > > > and for pts=5 prints: > > > {{1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 3, 4}, {1, 3, 5}, {1, 4, 5}, > > {2, 1, 3}, {2, 1, 4}, {2, 1, 5}, {2, 3, 4}, {2, 3, 5}, {2, 4, 5}, > > {3, 1, 2}, {3, 1, 4}, {3, 1, 5}, {3, 2, 4}, {3, 2, 5}, {3, 4, 5}, > > {4, 1, 2}, {4, 1, 3}, {4, 1, 5}, {4, 2, 3}, {4, 2, 5}, {4, 3, 5}, > > {5, 1, 2}, {5, 1, 3}, {5, 1, 4}, {5, 2, 3}, {5, 2, 4}, {5, 3, 4}} > > > and for pts=6 gives > > > {{1,2,3},{1,2,4},{1,2,5},{1,2,6},{1,3,4},{1,3,5},{1,3,6},{1,4,5},{1,4,6},{1 , > > 5, 6}, > > {2,1,3},{2,1,4},{2,1,5},{2,1,6},{2,3,4},{2,3,5},{2,3,6},{2,4,5}, > > {2,4,6},{2,5,6}, > > {3,1,2},{3,1,4},{3,1,5},{3,1,6},{3,2,4},{3,2,5},{3,2,6},{3,4,5}, > > {3,4,6},{3,5,6}, > > {4,1,2},{4,1,3},{4,1,5},{4,1,6},{4,2,3},{4,2,5},{4,2,6},{4,3,5}, > > {4,3,6},{4,5,6}, > > {5,1,2},{5,1,3},{5,1,4},{5,1,6},{5,2,3},{5,2,4},{5,2,6},{5,3,4}, > > {5,3,6},{5,4,6}, > > {6,1,2},{6,1,3},{6,1,4},{6,1,5},{6,2,3},{6,2,4},{6,2,5},{6,3,4}, > > {6,3,5},{6,4,5}} > > > pts will be in the range of 4-20 or so. Speed of this operation is not > > really critical. > > > The first entry in each list item ranges from 1 to pts. For any given > > value of it, the other two entries are the subsets of Range excluding > > the first entry. Seems simple but my solution is not. > > > Thank you for any tips. > > > Steve Gray > > Select[Tuples[Range[pts],3],Unequal@@#&&OrderedQ@Rest@#&] > > is shorter and gives the same results. Elegant Solution!