Re: Optimal number of sheets
- To: mathgroup at smc.vnet.net
- Subject: [mg58344] Re: [mg58324] Optimal number of sheets
- From: "David Park" <djmp at earthlink.net>
- Date: Tue, 28 Jun 2005 21:56:42 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
John,
Needs["DiscreteMath`Combinatorica`"]
optimalSheets::usage =
"optimalSheets[available][thickness] will return return the minimun
number of sheet combinations of available sheet thicknesses that will give
the overall thickness.";
optimalSheets[available : {_Integer?Positive
..}][thickness_Integer?Positive] :=
Module[
{partitionsOfn = Cases[Partitions[thickness], {(Alternatives @@ available)
..}],
minsheets},
minsheets = Min[Length /@ partitionsOfn];
Select[partitionsOfn, Length[#] == minsheets &]]
optimalSheets[{1, 2, 3, 4, 7}][6]
{{4, 2}, {3, 3}}
optimalSheets[{1, 2, 3, 4, 7}][15]
{{7, 7, 1}, {7, 4, 4}}
optimalSheets[{1, 2, 3, 4, 7}][25]
{{7, 7, 7, 4}}
optimalSheets[{1, 3}][8]
{{3, 3, 1, 1}}
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Erb, John [mailto:jerb at saint-lukes.org]
To: mathgroup at smc.vnet.net
Hello,
On a given occasion, I wish to create different thicknesses of a
material, ranging
say, for example, from 1 cm to 25 cm, in increments of 1 cm.
How can I, using Mathematica, determine the minimum number
of sheets of material I need?
The material comes in thicknesses of 1, 2, 3, 4, & 7 cm.
Thank you,
John C. Erb
email: John_C_Erb at prodigy.net