Re: array ordered
- To: mathgroup at smc.vnet.net
- Subject: [mg3180] Re: array ordered
- From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
- Date: Tue, 13 Feb 1996 02:29:37 -0500
- Organization: University of Colorado, Boulder
- Sender: owner-wri-mathgroup at wolfram.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
==== [MESSAGE SEPARATOR] ====