I’d be leaving Budapest after Christmas. I hear Budapest is even more beautiful during the Christmas season. That’s plausible. So I’d stay in Budapest until the last day of this year. Today I spent some time thinking about how much stuff I can take out of Budapest. Apparently, Lufthansa allows me to check in only one bag and carry on one bag. Ridiculous, right?
But anyways I need to figure what I can put into the bag to check in and what I’ll have to mail somehow to the States. I have a list of things I’ve bought so far and things I wish to buy + how much these things weigh. The tricky thing is that there’s no clear positive or negative correlation between things that I want (or prefer) to take and the weight of these things. For example, I have a cup that I like that weighs 1kg, a 0.8kg World War 2 Galilean binoculars I bought today that’s kind of expensive and that I really like, and another WW 2 artifact, a butterfly knife that weighs 0.5kg. I don’t really like the butterfly knife but I think it’s better if I put it in the checked bag rather than mail it. I feel U.S customs might delay its entry if I mail it.
So my dilemma is to try to fit all the articles I’ve bought, the ones that I plan to buy, and the ones that I already have into a 23kg bag. Let’s assume that the
weight of all the items I came with (altogether) is about 20kg. The remaining space available is obviously 3kg. Here’s a list of the potential articles:
Item | Weight | Preference |
---|---|---|
Mashery Cup | 1kg | 4 |
WW2 Galilean binoculars | 0.5kg | 5 |
Bufferfly knife | 0.5kg | 2 |
Camera | 0.5kg | 4 |
Laptop | 1.5kg | 6 |
Soccer boots | 1.5kg | 3 |
Textbooks | 2.0kg | 3 |
To make it easier for me to know which items I should take and which I shouldn’t,
I associated each item with a preference number. The more I like an item, the higher
it’s preference number.
Another way of stating this problem is: I have a max space (3kg). I need to
fill that space with items from the above list. But in selecting the items, I wish
to maximize the total Preference of the selected items.
This problem is pretty easy to solve and there are many known heuristics and
algorithms you can use to solve this problem. Check out the solution here.
You should use a knapsack rather than a suitcase 😉
Right on, Eli!