How do I efficiently partition a set of item pairs with varying quantities











up vote
0
down vote

favorite












Apologies in advance if my terminology is off. I'm not a mathematician (just a programmer).



I have a set of item pairs (a shopping cart) where each item has a quantity



1x item A
1x item B
2x item C
1x item D
1x item E


I have a discount code that requires a minimum quantity of items in the cart in order to be applicable. The goal is to maximize the discount.



If the minimum was 3 items, there would be two candidates for this cart:



(A, B, C, D, E) = $50 discount
(A, B, C) (C, D, E) = $
60 discount (since we can use 'C' twice)


Rather than brute-forcing it, is there an algorithm used for calculating the optimal way to partition sets of pairs like these? Or even a hint of a branch of maths I should be looking into?



Thanks in advance for any insight.










share|cite|improve this question






















  • It's not clear how this is being assigned, is it $10 per unique item in a subgroup?
    – Ian
    Nov 14 at 23:06










  • Yes, exactly. $10 per item in a subgroup. And an item will only appear once per subgroup.
    – Alex Dunae
    Nov 14 at 23:21










  • What do you mean by pairs? I only see two of one thing, that is C. You have to specify the rules. It appears that you cannot apply the discount to two of the same item in a group. You can simply make groups of $3$, starting with the most common items. If you have one or two left over, add them into some group. That gets every item into a group as long as there are at least $3$ and not to many of one kind. What is wrong with that? That will help clarify the question.
    – Ross Millikan
    Nov 15 at 0:48















up vote
0
down vote

favorite












Apologies in advance if my terminology is off. I'm not a mathematician (just a programmer).



I have a set of item pairs (a shopping cart) where each item has a quantity



1x item A
1x item B
2x item C
1x item D
1x item E


I have a discount code that requires a minimum quantity of items in the cart in order to be applicable. The goal is to maximize the discount.



If the minimum was 3 items, there would be two candidates for this cart:



(A, B, C, D, E) = $50 discount
(A, B, C) (C, D, E) = $
60 discount (since we can use 'C' twice)


Rather than brute-forcing it, is there an algorithm used for calculating the optimal way to partition sets of pairs like these? Or even a hint of a branch of maths I should be looking into?



Thanks in advance for any insight.










share|cite|improve this question






















  • It's not clear how this is being assigned, is it $10 per unique item in a subgroup?
    – Ian
    Nov 14 at 23:06










  • Yes, exactly. $10 per item in a subgroup. And an item will only appear once per subgroup.
    – Alex Dunae
    Nov 14 at 23:21










  • What do you mean by pairs? I only see two of one thing, that is C. You have to specify the rules. It appears that you cannot apply the discount to two of the same item in a group. You can simply make groups of $3$, starting with the most common items. If you have one or two left over, add them into some group. That gets every item into a group as long as there are at least $3$ and not to many of one kind. What is wrong with that? That will help clarify the question.
    – Ross Millikan
    Nov 15 at 0:48













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Apologies in advance if my terminology is off. I'm not a mathematician (just a programmer).



I have a set of item pairs (a shopping cart) where each item has a quantity



1x item A
1x item B
2x item C
1x item D
1x item E


I have a discount code that requires a minimum quantity of items in the cart in order to be applicable. The goal is to maximize the discount.



If the minimum was 3 items, there would be two candidates for this cart:



(A, B, C, D, E) = $50 discount
(A, B, C) (C, D, E) = $
60 discount (since we can use 'C' twice)


Rather than brute-forcing it, is there an algorithm used for calculating the optimal way to partition sets of pairs like these? Or even a hint of a branch of maths I should be looking into?



Thanks in advance for any insight.










share|cite|improve this question













Apologies in advance if my terminology is off. I'm not a mathematician (just a programmer).



I have a set of item pairs (a shopping cart) where each item has a quantity



1x item A
1x item B
2x item C
1x item D
1x item E


I have a discount code that requires a minimum quantity of items in the cart in order to be applicable. The goal is to maximize the discount.



If the minimum was 3 items, there would be two candidates for this cart:



(A, B, C, D, E) = $50 discount
(A, B, C) (C, D, E) = $
60 discount (since we can use 'C' twice)


Rather than brute-forcing it, is there an algorithm used for calculating the optimal way to partition sets of pairs like these? Or even a hint of a branch of maths I should be looking into?



Thanks in advance for any insight.







algorithms






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Nov 14 at 23:05









Alex Dunae

1011




1011












  • It's not clear how this is being assigned, is it $10 per unique item in a subgroup?
    – Ian
    Nov 14 at 23:06










  • Yes, exactly. $10 per item in a subgroup. And an item will only appear once per subgroup.
    – Alex Dunae
    Nov 14 at 23:21










  • What do you mean by pairs? I only see two of one thing, that is C. You have to specify the rules. It appears that you cannot apply the discount to two of the same item in a group. You can simply make groups of $3$, starting with the most common items. If you have one or two left over, add them into some group. That gets every item into a group as long as there are at least $3$ and not to many of one kind. What is wrong with that? That will help clarify the question.
    – Ross Millikan
    Nov 15 at 0:48


















  • It's not clear how this is being assigned, is it $10 per unique item in a subgroup?
    – Ian
    Nov 14 at 23:06










  • Yes, exactly. $10 per item in a subgroup. And an item will only appear once per subgroup.
    – Alex Dunae
    Nov 14 at 23:21










  • What do you mean by pairs? I only see two of one thing, that is C. You have to specify the rules. It appears that you cannot apply the discount to two of the same item in a group. You can simply make groups of $3$, starting with the most common items. If you have one or two left over, add them into some group. That gets every item into a group as long as there are at least $3$ and not to many of one kind. What is wrong with that? That will help clarify the question.
    – Ross Millikan
    Nov 15 at 0:48
















It's not clear how this is being assigned, is it $10 per unique item in a subgroup?
– Ian
Nov 14 at 23:06




It's not clear how this is being assigned, is it $10 per unique item in a subgroup?
– Ian
Nov 14 at 23:06












Yes, exactly. $10 per item in a subgroup. And an item will only appear once per subgroup.
– Alex Dunae
Nov 14 at 23:21




Yes, exactly. $10 per item in a subgroup. And an item will only appear once per subgroup.
– Alex Dunae
Nov 14 at 23:21












What do you mean by pairs? I only see two of one thing, that is C. You have to specify the rules. It appears that you cannot apply the discount to two of the same item in a group. You can simply make groups of $3$, starting with the most common items. If you have one or two left over, add them into some group. That gets every item into a group as long as there are at least $3$ and not to many of one kind. What is wrong with that? That will help clarify the question.
– Ross Millikan
Nov 15 at 0:48




What do you mean by pairs? I only see two of one thing, that is C. You have to specify the rules. It appears that you cannot apply the discount to two of the same item in a group. You can simply make groups of $3$, starting with the most common items. If you have one or two left over, add them into some group. That gets every item into a group as long as there are at least $3$ and not to many of one kind. What is wrong with that? That will help clarify the question.
– Ross Millikan
Nov 15 at 0:48















active

oldest

votes











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2998938%2fhow-do-i-efficiently-partition-a-set-of-item-pairs-with-varying-quantities%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2998938%2fhow-do-i-efficiently-partition-a-set-of-item-pairs-with-varying-quantities%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Plaza Victoria

In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...