Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How can I calculate the right combination of postage stamps?

by Limbic~Region (Chancellor)
on Nov 26, 2008 at 15:39 UTC ( #726130=note: print w/replies, xml ) Need Help??


in reply to How can I calculate the right combination of postage stamps?

brian_d_foy,
You can look at this problem two different ways. The first way is a variation on the bin packing problem. There are many threads here as well as a number of modules on CPAN. There are heuristic approaches that are much faster than brute force but they don't guarantee no waste. If I get a chance later, I will augment this node with some links but Super Search is your friend.

The second way, is restricted integer partitioning. See How to generate restricted partitions of an integer and puzzle: how many ways to make $100 for instance. This isn't exactly your problem because it assumes you have an unlimited number of each stamp denomination. On the other hand, it is interesting to learn about. And while we are at it, consider that unrestricted integer partions are also fun - see below for a list:

Cheers - L~R

  • Comment on Re: How can I calculate the right combination of postage stamps?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://726130]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2023-10-04 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?