Re: array ordered

• Subject: [mg3180] Re: array ordered
• From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
• Date: 14 Feb 1996 07:29:03 -0600
• Approved: usenet@wri.com
• Distribution: local
• Newsgroups: wri.mathgroup
• Organization: University of Colorado, Boulder
• Sender: daemon at wri.com

```In article <4fhh6k\$963 at dragonfly.wolfram.com>,
DR JOHN C ERB <TTCJ34A at prodigy.com> wrote:
>Greetings All;
>
> I have six pieces of plastic of thickness:
>  thick={0.48,0.71,1.41,3.45,5.61,13.49};
>
>How can I use Mathematica to get an array, ordered by
>increasing thicknesses of plastic, giving the
>63 different thicknesses, and combination of pieces
>needed to give each thickness?

I'll give a solution using only the first 3 thicknesses as an example,
to save space.  The code should work for the longer list as well.

thick={0.48,0.71,1.41};

Outer[List, ##]& @@ Table[{0,1}, {Length[thick]}]
{{{{0, 0, 0}, {0, 0, 1}}, {{0, 1, 0}, {0, 1, 1}}},
{{{1, 0, 0}, {1, 0, 1}}, {{1, 1, 0}, {1, 1, 1}}}}

Flatten[%, Length[thick]-1]
{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1},
{1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}}

combos = Drop[%, 1]
{{0, 0, 1}, {0, 1, 0}, {0, 1, 1}, {1, 0, 0},
{1, 0, 1}, {1, 1, 0}, {1, 1, 1}}

{#.thick, #}& /@ combos
{{1.41, {0, 0, 1}}, {0.71, {0, 1, 0}}, {2.12, {0, 1, 1}}, {0.48, {1, 0, 0}},
{1.89, {1, 0, 1}}, {1.19, {1, 1, 0}}, {2.6, {1, 1, 1}}}

Sort[%]
{{0.48, {1, 0, 0}}, {0.71, {0, 1, 0}}, {1.19, {1, 1, 0}}, {1.41, {0, 0, 1}},
{1.89, {1, 0, 1}}, {2.12, {0, 1, 1}}, {2.6, {1, 1, 1}}}

Dave Wagner
Principia Consulting
(303) 786-8371
dbwagner at princon.com
http://www.princon.com/princon

```

• Prev by Date: MathLink function: Global variable?
• Next by Date: MathLink function: Global variable?
• Previous by thread: Re: array ordered
• Next by thread: Re: array ordered