Coming soon - Get a detailed view of why an account is flagged as spam!
view details
13
Is this problem tractable? It seems like a variant of the rucksack problem, but I’m not sure!
Post Body

Let’s say you are in a magical supermarket on another planet. And the rules on this planet are that you only pay 1 Schmeckle for each type of ingredient in your shopping basket.

So let’s say your shopping list is:
- Chocolate cake (contains chocolate, butter, sugar)
- Sugar
- Banana
- Banana yoghurt (contains milk, sugar, banana)
- Butter
- Milk
- Strawberry milk (contains strawberry and milk)
- 1000 other things (coz you’re gonna throw a big party)

The chocolate cake contains sugar and butter so if you put the chocolate cake in the first basket, then you can also get the sugar and butter FOR FREE, as long as they are in the same basket!

But now if you put chocolate cake, sugar, and butter in Basket A, you realize the the banana yoghurt contains sugar. So if you add the banana yoghurt, you only need to pay for the milk ingredient part — and now if you add milk and banana, you get them for free, etc.

Now further suppose that the baskets are magical or something (I can’t really come up with a good physical analogy for this, so just use your imagination!) — they can contain any number of items, but can only contain up to M ingredients total. So for example, with M=5, if you add chocolate cake, and then sugar and butter that's 3 ingredients total; then you can add banana yoghurt, milk and banana, for a total of 5 ingredients -- so now you can't add the strawberry milk, as you are up the the maximum number of M ingredients per basket.

You can use as many baskets as you want, but the ingredient discount only applies per basket. So if you have sugar in two baskets, you will pay 1 Schmeckle for each sugar in each basket. In the above example, if you add strawberry milk to Basket B, you must now pay 1 Schmeckle each for milk and strawberry.

Now the problem statement is — what is the best way to distribute all the food on your shopping list among the baskets, in order to minimize the total cost at the checkout?

Easy version: Assume that you can use as many baskets as you want.

Difficult version: Assume that you are limited to N baskets, and you want to fill all the baskets.

EDIT: clarified example and formatting

Author
Account Strength
100%
Account Age
14 years
Verified Email
Yes
Verified Flair
No
Total Karma
78,403
Link Karma
10,302
Comment Karma
66,821
Profile updated: 4 days ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
6 years ago