Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to get a formula for this problem, and also to know what "area" of math the problem would fall into. This is an abstraction of a system used within a game.


Suppose an item has four cost attributed to it, say the cost of its four materials A B C and D Item X cost: 10 A, 10 B, 20 C and 5D

You have different amount of materials A, B, C, and D in storage. You also have an exchange rate. Your exchange rate tell you how much of any material is needed to make another material. The fixed exchange rate is 2:1. This means you can convert 2 of one material into 1 of another material.


In storage I have 20,000 of material A, 30,000 of material B, 48,000 of material C and 50,000 of material D. I want to know two things:

I. How to make the MAXIMUM number of Item X's that I can, by utilizing the conversion process to change excess of one material into another. What's the formula? The answer for the MAX is of secondary importance.

II. How to bring all my material amount to equilibrium utilizing the conversion process. i.e. making A = B = C = D by converting higher amount materials into lower amounts until they are all the same. What's the formula? The answer of their balance point is of secondary importance.

For some reason this reminds me of "moments" and finding the center of polygon regions in the plane. In any case, I'd love to know the answer to my questions above, and what type of math this categorizes as. Thank you!

share|cite|improve this question
When you say "cost" do you mean something financial, or the amounts of $A$, $B$, $C$ and $D$ to make one of $X$? If the former, then it seems irrelevant unless there is a market somewhere; if the latter then why do you want "A=B=C=D"? – Henry Apr 20 '12 at 20:43
I guess the best thing is to give a concrete example. Call A 'Gold', B 'Food', C 'Iron', D 'Lumber'. Then let Item X be a Knight: A Knight costs 10 Gold, 10 Food, 20 Iron, and 5 Lumber. 1st question is how many Knights can I make based on the material amounts I have in storage? Wanting A=B=C=D s the 2nd question. It does not have to do with the Knight at all. The reason why I'd want to balance the materials is because there is a LIMIT on how much of each material I can store. At some point it's best to convert to another material before reaching a storage max. Does that help? – VISQL Apr 20 '12 at 20:57
Have you heard about linear programming? – dtldarek Apr 20 '12 at 22:01
I have. I could not figure out how to formulate this into one of those maximize Z given x, y, z, constraints. – VISQL Apr 23 '12 at 23:38

It is easier to answer II before I. Let's take your $A=B=C=D$ target and ignore the "cost".

You start by noticing you have far too much of $D$ and not enough of $A$, so you start converting until you have either the same amount of $D$ as $C$ or the same amount of $A$ as $B$; it turns out to be the former.

Then notice you have too much of $D$ and $C$ and not enough of $A$, so you start converting until you have either the same amount of $D$ and $C$ as $B$ or the same amount of $A$ as $B$; it turns out to be the latter.

Then notice you have too much of $D$ and $C$ and not enough of $A$ and $B$, so you start converting until you have the same amount of $D$ and $C$ as $A$ and $B$.

That then tells you the maximum $X$ you can make using the conversion process.

If the costs matter (if you need ten As, ten Bs, twenty Cs and five Ds to make one X) then divide the stock by the amounts needed and then follow the same process of converting from the extremes.

share|cite|improve this answer

You have enough A to make 2000 units, B to make 3000, C to make 2400, and D to make 10000. Without conversion, you can make 2000, leaving you (0, 10000, 8000, 40000). You now could make 400 more if you had 4000 A, so convert 8000 D. You now have 2400 units and (0, 6000, 0, 30000). Each new unit takes 5D, 10 B, and 60 of either, so we can make 480 more and we get a total of 2880.

Added in response to comment: thinking further, for this scenario, you can just consider the total of elements required because they are interconvertible at the same rate. To make n items requires 10n + 10max(n-2000,0)+10n+10max(n-3000,0)+20n+20max(n-2400,0)+5n+5max(n-10000,0) units of raw materials. You can search for an n that equates this to the 148000 that you have. Each pair of terms is one material. For example the 10n is the A used, the 10max(n-2000,0) is the material converted to A.

share|cite|improve this answer
Thank you Ross. Is there a way to formulate this with variables, so that it isn't constantly case by case - and so it can be solve at once? I want to know exactly how much of anything to convert to anything else in the beginning, convert only once and get my maximum when making the Item. – VISQL Apr 20 '12 at 21:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.