1

first time posting, with a probably very simple question for you. This is something that I need for work:

I have a container to fill with exactly 250 objects, and a maximum weight capacity of 2339g I have two kinds of objects to fill the container with:

  • The primary objects that I want to use, with a weight of 18g each
  • The filler objects, with a weight of 5g each.

What I want to do is fill the container with as many primary objects as possible, and then fill the rest of the remaining 250 spaces with filler objects. I cannot exceed the maximum weight capacity of 2339g.

I could have solved this in 5 minutes whe I was at highscool, but those days are long gone... Please advise if the format of the question is not appropriate.

Many thanks!

Deagol
  • 13
  • Cheating solution? Use Excel to calculate the weight of $n$ primaries and $250-n$ fillers, one row for each $n$. Find the combination with the largest weight less than your limit. – Ethan Bolker Aug 22 '18 at 12:15
  • Yeah, I did something similar in excel, but I'm trying to look for a more elegant solution for this problem, as some of the object variables will vary over time. But for now I will brute-force my way out of this problem, as you suggested. Thanks! – Deagol Aug 22 '18 at 12:21

1 Answers1

1

Let $x$ and $y$ denote the number of primary and filler objects, respectively. We want to solve the following system of inequalities $$18x+5y\leq2339\\x+y=250$$ We can rearrange the second equation into $y=250-x$ and plug it into the first one. Simplify the inequality, and you will have $$ 13x\leq 1089$$ The highest integer value of $x$ that you can have is 83, and so you can fill in 83 primary and 167 filler objects.

Indeed, $83(18)+167(5)=2329<2339$ and $84(18)+166(5)=2342>2339$ so 83 is the maximum number of primary objects that you can fill in

Alvin
  • 66
  • So far so good - but the question specifies using exactly $250$ objects. That means the correct solution will have to use fewer primaries and many more fillers. – Ethan Bolker Aug 22 '18 at 12:12
  • I was a bit confused with the wording of the question. I interpreted the question as what is the maximum number of primary object you can fill in given the weight constraint, and you can only fill the container for up to 250 objects. But thanks for the clarification. – Alvin Aug 22 '18 at 12:16
  • Sorry if the wording was a bit confusing. I do need the container to be full with a total of 250 objects. – Deagol Aug 22 '18 at 12:20
  • Hi Deagol, I just edited my post with the 250 objects requirement. – Alvin Aug 22 '18 at 12:30
  • Your second solution is fine. You should remove everything above it. – Christian Blatter Aug 22 '18 at 12:57
  • Fantastic! Thank you! – Deagol Aug 22 '18 at 17:57