Re: array ordered

• Subject: [mg3178] Re: array ordered
• From: Jorma.Virtamo at vtt.fi (Jorma Virtamo)
• Date: 14 Feb 1996 02:02:16 -0600
• Approved: usenet@wri.com
• Distribution: local
• Newsgroups: wri.mathgroup
• Organization: Wolfram Research, Inc.
• Sender: daemon at wri.com

```
TTCJ34A at prodigy.com (DR JOHN C ERB) wrote:
>
>  I have six pieces of plastic of thickness:
>   thick={0.48,0.71,1.41,3.45,5.61,13.49};
>
> By using these in various combinations
> (i.e., 1 piece, 2 pieces,... 6 pieces),
> I can have:
>       numberthick={1,2,3,4,5,6};
>       total = Apply[Plus,Map[Binomial[6,#]&,numbthick]];
>       total = 63
> 63 different thickness.
>
> 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?
>

Here is one solution:

First, form a list of all possible piece combinations,

In[1]:=  piececombs=Flatten[Array[List,{2,2,2,2,2,2},0],5]

Out[1]=
{{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 1, 1},
{0, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 0, 1},
{0, 0, 0, 1, 1, 0},  etc

where 1 (0) means that a piece is (is not) used in the combination.
There are 64 combinations, not 63, since the empty combination is
also included (of course, one can drop it by Drop[piececombs,1]).

Then prepend to each piece combination in the list its thickness and
finally sort the whole list:

In[2]:= Sort[{Plus @@ (#*thick), #}& /@ piececombs]//MatrixForm

Out[2]=
0              {0, 0, 0, 0, 0, 0}
0.48           {1, 0, 0, 0, 0, 0}
0.71           {0, 1, 0, 0, 0, 0}
1.19           {1, 1, 0, 0, 0, 0}
...
...
23.96          {0, 0, 1, 1, 1, 1}
24.44          {1, 0, 1, 1, 1, 1}
24.67          {0, 1, 1, 1, 1, 1}
25.15          {1, 1, 1, 1, 1, 1}

-- Jorma Virtamo

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jorma Virtamo                      VTT Information Technology
phone: +358 0 456 5612             Telecommunications
fax:   +358 0 455 0115             P.O. Box 1202
email: jorma.virtamo at vtt.fi        FIN-02044 VTT
web:   http://www.vtt.fi/tte/      Finland

```

• Prev by Date: Re: array ordered
• Next by Date: positions open at WRI
• Previous by thread: Re: array ordered
• Next by thread: Re: array ordered