Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: array ordered

  • Subject: [mg3190] Re: array ordered
  • From: espen.haslund at fys.uio.no (Espen Haslund)
  • Date: 14 Feb 1996 07:14:02 -0600
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Universitet i Oslo
  • Sender: daemon at wri.com

In article <4fhh6k$963 at dragonfly.wolfram.com>, TTCJ34A at prodigy.com says...
>
>Greetings All;
>
> 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?
>
>Thank you for any help
>
Greetings John;

Below is one possible solution. I am sure 
that more elegant (and general) methods are available.
However, this solution demonstrates a nice thing about
Mathematica: Even if you do not know how to do a 
thing properly, you can usually Do[ it anyway.

Hope this is of some help.
- Espen


take2[list_] := 
Module[{ll = Length[list], res={}},
   Do[AppendTo[res, Union[list[[{i, j}]] ] ], {i,1,ll},{j,1,ll}];
   Union[res]
]

take3[list_] := 
Module[{ll = Length[list], res={}},
   Do[AppendTo[res, Union[list[[{i, j, k}]] ] ],{i,1,ll},
    {j,1,ll},{k,1,ll}];
   Union[res]
]

getThickness[list_] :=
Module[{res, res1},
   res = take3[list];
   res1 = Map[Complement[list, #] &, take2[list] ];
   res = Join[res, res1, {list}];
   Do[res[[i]] = {Plus @@ res[[i]], res[[i]]}, {i, 1, Length[res]}]; 
   Sort[res]
]

thick={0.48,0.71,1.41,3.45,5.61,13.49}
PaddedForm[ColumnForm[getThickness[thick] ], {4,2} ]

(* - resulted in -
//PaddedForm= {  0.48, {  0.48}}
              {  0.71, {  0.71}}
              {  1.19, {  0.48,   0.71}}
              {  1.41, {  1.41}}
              {  1.89, {  0.48,   1.41}}
              {  2.12, {  0.71,   1.41}}
              {  2.60, {  0.48,   0.71,   1.41}}
              {  3.45, {  3.45}}
              {  3.93, {  0.48,   3.45}}
              {  4.16, {  0.71,   3.45}}
              {  4.64, {  0.48,   0.71,   3.45}}
              {  4.86, {  1.41,   3.45}}
              {  5.34, {  0.48,   1.41,   3.45}}
              {  5.57, {  0.71,   1.41,   3.45}}
              {  5.61, {  5.61}}
              {  6.05, {  0.48,   0.71,   1.41,   3.45}}
              {  6.09, {  0.48,   5.61}}
              {  6.32, {  0.71,   5.61}}
              {  6.80, {  0.48,   0.71,   5.61}}
              {  7.02, {  1.41,   5.61}}
              {  7.50, {  0.48,   1.41,   5.61}}
              {  7.73, {  0.71,   1.41,   5.61}}
              {  8.21, {  0.48,   0.71,   1.41,   5.61}}
              {  9.06, {  3.45,   5.61}}
              {  9.54, {  0.48,   3.45,   5.61}}
              {  9.77, {  0.71,   3.45,   5.61}}
              { 10.25, {  0.48,   0.71,   3.45,   5.61}}
              { 10.47, {  1.41,   3.45,   5.61}}
              { 10.95, {  0.48,   1.41,   3.45,   5.61}}
              { 11.18, {  0.71,   1.41,   3.45,   5.61}}
              { 11.66, {  0.48,   0.71,   1.41,   3.45,   5.61}}
              { 13.49, { 13.49}}
              { 13.97, {  0.48,  13.49}}
              { 14.20, {  0.71,  13.49}}
              { 14.68, {  0.48,   0.71,  13.49}}
              { 14.90, {  1.41,  13.49}}
              { 15.38, {  0.48,   1.41,  13.49}}
              { 15.61, {  0.71,   1.41,  13.49}}
              { 16.09, {  0.48,   0.71,   1.41,  13.49}}
              { 16.94, {  3.45,  13.49}}
              { 17.42, {  0.48,   3.45,  13.49}}
              { 17.65, {  0.71,   3.45,  13.49}}
              { 18.13, {  0.48,   0.71,   3.45,  13.49}}
              { 18.35, {  1.41,   3.45,  13.49}}
              { 18.83, {  0.48,   1.41,   3.45,  13.49}}
              { 19.06, {  0.71,   1.41,   3.45,  13.49}}
              { 19.10, {  5.61,  13.49}}
              { 19.54, {  0.48,   0.71,   1.41,   3.45,  13.49}}
              { 19.58, {  0.48,   5.61,  13.49}}
              { 19.81, {  0.71,   5.61,  13.49}}
              { 20.29, {  0.48,   0.71,   5.61,  13.49}}
              { 20.51, {  1.41,   5.61,  13.49}}
              { 20.99, {  0.48,   1.41,   5.61,  13.49}}
              { 21.22, {  0.71,   1.41,   5.61,  13.49}}
              { 21.70, {  0.48,   0.71,   1.41,   5.61,  13.49}}
              { 22.55, {  3.45,   5.61,  13.49}}
              { 23.03, {  0.48,   3.45,   5.61,  13.49}}
              { 23.26, {  0.71,   3.45,   5.61,  13.49}}
              { 23.74, {  0.48,   0.71,   3.45,   5.61,  13.49}}
              { 23.96, {  1.41,   3.45,   5.61,  13.49}}
              { 24.44, {  0.48,   1.41,   3.45,   5.61,  13.49}}
              { 24.67, {  0.71,   1.41,   3.45,   5.61,  13.49}}
              { 25.15, {  0.48,   0.71,   1.41,   3.45,   5.61,  13.49}}
*)



  • Prev by Date: Re: array ordered
  • Next by Date: Re: array ordered
  • Previous by thread: Re: array ordered
  • Next by thread: Re: array ordered