Re: There must be a better way.

• To: mathgroup at smc.vnet.net
• Subject: [mg111935] Re: There must be a better way.
• From: ADL <alberto.dilullo at tiscali.it>
• Date: Fri, 20 Aug 2010 07:05:44 -0400 (EDT)
• References: <i4j40i\$qrg\$1@smc.vnet.net>

```You might consider this looping code:

range=Range[pts];
list=Reap @
Do[
Do[
Do[
If[j<k,Sow@{i,j,k}],
{k,DeleteCases[range,i | j]}
],
{j,DeleteCases[range,i]}
],
{i,range}
];
result=list[[2,1]];
SplitBy[result,First]

The SplitBy instruction is just to make the result print like your
tables.

On 19 Ago, 13:19, "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
>
> 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: Re: wrong result in solving equation and parametric ploting
• Next by Date: Re: Formatting - bold characters as variables?
• Previous by thread: Re: There must be a better way.
• Next by thread: Re: There must be a better way.