There must be a better way.

• To: mathgroup at smc.vnet.net
• Subject: [mg111918] There must be a better way.
• From: "S. B. Gray" <stevebg at ROADRUNNER.COM>
• Date: Thu, 19 Aug 2010 07:19:52 -0400 (EDT)

```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

```

• Prev by Date: Formatting - bold characters as variables?
• Next by Date: Re: Creating a simple state inspector for Mathematica
• Previous by thread: Re: Formatting - bold characters as variables?
• Next by thread: Re: There must be a better way.