Cargo

Fit the most valuable load you can into a hold that will only take so much weight. Taking the best value-per-kilo item first is a good rule of thumb and it is not a correct one, which is where the whole puzzle lives.

How to play

Each crate is labelled with what it is worth, what it weighs and its value per pound, and tapping one loads it aboard; tap it again to take it off.

  1. Start with value for weight Load the best value per pound first. It gets you close and it is the right instinct.
  2. Then look at what is left over If the wagon has room the good crates cannot fill, a worse crate that fits exactly may be worth more than the room it uses.
  3. Try swapping one big for two small That is almost always where the missing value is hiding.
Full instructions

In depth

Packing a wagon when the obvious rule is wrong

Why sorting by value per pound looks right but fails, how the game finds the true best load, what the swap trick is, and how to spot the crate combinations that beat the greedy approach every time.

Screenshot: How to play Cargo
How to play Cargo as it appears when the page opens.

The puzzle in one sentence

A wagon can carry a fixed weight. A set of crates sits in front of you. Each crate has a value and a weight. You want the most valuable load the wagon can hold. Nothing may be split. Either a crate goes in whole or it stays behind.

The game tells you the best possible load before you start. Your job is to find it. Every wagon in this game is chosen so that the obvious approach falls short of that number. If it were easy, it would not be a puzzle.

What each crate shows you

Every crate on the board displays three numbers. The top number is its value. The middle number is its weight. The bottom number is its value per pound, shown to one decimal place. That last figure is value divided by weight, and it measures how efficient the crate is.

A crate worth 12 that weighs 4 has a value per pound of 3.0. A crate worth 10 that weighs 3 has a value per pound of 3.3. By this measure the second crate is better. The natural instinct is to load the highest value per pound first and keep going until the wagon is full. That instinct works most of the time in the real world. It does not work here, and understanding why is the point of the game.

Why the greedy rule fails

Sorting by value per pound and loading from the top is called the greedy approach. It fails when the items cannot be divided. Suppose the wagon holds 10 pounds. Crate A is worth 10 and weighs 6 (value per pound 1.7). Crate B is worth 8 and weighs 5. Crate C is worth 8 and weighs 5.

The greedy rule takes B first (value per pound 1.6) and then cannot fit A. It looks at C, which also weighs 5, so it takes C. The load is B plus C for a total value of 16 in 10 pounds.

But if you had taken A plus one of the others, you get 10 plus 8 for 18. Wait, that weighs 11 and does not fit. So the greedy answer of 16 is actually correct here. The game would not ship this wagon, because it only uses ones where greedy falls short.

A real example from the game might have a crate with outstanding value per pound that weighs 9 in a wagon of 10. Taking it leaves only 1 pound free, and nothing else fits. The total value is just that one crate. But two less efficient crates weighing 5 each might add up to more. That is the gap this game asks you to find.

Controls and how loading works

Tap a crate to load it onto the wagon. Tap it again to take it off. The bar at the top fills up to show how much of the wagon's capacity you have used. A fraction next to it shows the exact weight.

Crates that no longer fit are greyed out. If the wagon has 3 pounds of room left and a crate weighs 5, that crate is dimmed. Crates already on the wagon are highlighted and can always be tapped to remove them.

The scoreboard shows three numbers. Load worth is the total value of everything currently on the wagon. Weight shows how much of the capacity is used. Best possible is the true maximum value, which the game has already worked out.

How the game knows the best load

The best possible value is not a guess. The game computes it exactly using a method called dynamic programming. It builds up the answer weight by weight. First it finds the best load for a wagon of size 1, then size 2, then size 3, all the way up to the real capacity. At each step it checks whether adding each crate improves the best known value for that weight.

By the time it reaches the actual wagon capacity, it has the true maximum. This is the standard solution to the knapsack problem. It works quickly as long as the capacity is a reasonable number, and every wagon in this game has a modest capacity by design.

The game also checks the greedy answer before it ships a puzzle to you. If greedy already finds the best load, the puzzle is rejected and a new one is generated. Every wagon you see is one where the shortcut fails.

The swap trick

The fastest way to improve a greedy load is to try swapping one large crate for two smaller ones. The greedy approach tends to fill the wagon with the most efficient items, but it often leaves a gap that nothing fits into. That wasted space is where the missing value hides.

Look at the room left after loading the best value per pound crates. If there is space for nothing, try removing the heaviest crate you loaded. That opens up room. Now check whether two lighter crates can fill that room with more total value than the one you removed.

This one-for-two swap finds the right answer on most of the boards this game generates. When it does not, try a one-for-three swap or look at whether two medium crates could be replaced by three small ones.

Difficulty levels and what changes

The small wagon gives you six crates and a capacity of 15. The medium wagon gives eight crates and a capacity of 22. The large wagon gives ten crates and a capacity of 30.

More crates means more combinations to consider. With six crates there are 64 possible subsets. With ten there are 1,024. You will not check all of them in your head, but the swap trick still works. Start greedy, then look for one substitution. The game counts your taps, so the fewer moves you make, the better your score.

A full wagon is not always best

It is tempting to fill every last pound of capacity. Sometimes that is wrong. If the only crate that fits the remaining space has terrible value, you might be better off leaving the space empty. The goal is maximum value, not maximum weight.

The game does not penalise unused capacity. Only the total value matters. A load worth 45 in 18 of 22 pounds beats a load worth 42 in 22 of 22 pounds. Do not chase a full bar.

Mistakes that make the puzzle harder

  • Trusting value per pound without question. It is a useful starting point, not a guarantee. Check the total before you submit.
  • Loading crates one by one without looking at the full set first. Scan all the crates, note which pairs add up to a nice total, then start loading.
  • Forgetting to unload. A crate you placed early might be the one blocking the better answer. Tap it off and try something else. Unloading costs a tap but costs nothing in value.
  • Ignoring small crates. A crate worth 5 that weighs 2 does not look exciting until you realise it fills the exact gap a bigger crate left behind.
  • Giving up when the greedy answer is close. If greedy gets you to 42 and the best is 45, the difference is usually one swap. Look for it.
  • Assuming the order matters. It does not. Only which crates end up on the wagon at the end counts. You can load and unload in any order.

The knapsack problem beyond the game

This puzzle is a version of the knapsack problem, one of the most studied problems in computer science. It was included in Richard Karp's original list of twenty-one problems that are NP-complete, meaning there is no known shortcut that always finds the answer quickly as the number of items grows.

What makes it manageable in practice is that the capacity is usually a small number. The dynamic programming approach builds the answer in time proportional to the number of items multiplied by the capacity. For a wagon of 30 with ten crates, that is 300 steps. For a cargo ship with a million containers, the same method would be too slow. That boundary between easy in practice and hard in theory is what makes the knapsack problem interesting.

Nothing is uploaded

The crate values, the wagon capacity, and the best answer are all generated and solved inside your browser. Your loading attempts stay on your machine. There is no server keeping track of your moves. Closing the tab is the only cleanup needed.

Help

How to play Cargo

Each crate is labelled with what it is worth, what it weighs and its value per pound, and tapping one loads it aboard; tap it again to take it off. Nothing can be split, so a crate is either loaded whole or left on the quay. The best possible total is printed at the top from the start, so you always know how far off you are.

Start with value for weight

Load the best value per pound first. It gets you close and it is the right instinct.

Then look at what is left over

If the wagon has room the good crates cannot fill, a worse crate that fits exactly may be worth more than the room it uses.

Try swapping one big for two small

That is almost always where the missing value is hiding.

Aim for the exact number

The best possible load is shown, so you know when you have it.

The knapsack problem

Choosing the most valuable set of things that fits inside a limit is the knapsack problem, and it sits on an interesting boundary. If the items could be divided — if you could take two thirds of a crate — the answer would be trivial: sort by value per pound, take greedily, and cut the last one to fit. The moment items must be taken whole or not at all, that argument collapses, and the problem becomes NP-complete: one of Karp’s original twenty-one from 1972. What saves it in practice is that the answer can be built up weight by weight — the best load for a wagon of size ten is worked out from the best loads for every smaller wagon — which is quick as long as the capacity is a modest number. That is how this board knows the answer, and every wagon here is chosen so that the value-for-weight rule falls short of it.

Good to know

A full wagon is not always the best

Filling every last pound with something poor can be worse than leaving room.

Splitting would make it easy

If crates could be cut up, value for weight would be exactly right. The refusal to split is the whole difficulty.

Heavy crates are greyed out

Anything that no longer fits is dimmed, so you can see your options at a glance.

Unloading is free

Only the load you finish with counts.

Common questions

Can I take part of a crate?
No, and that single restriction is what makes the problem hard.
Is the best value per pound always worth taking?
Not always. Every wagon here is one where that rule misses the best load.
Must the wagon be completely full?
No. Sometimes the best load leaves room.
Does the order I load them matter?
Not at all. Only which crates end up aboard.
Is the best-possible figure exact?
Yes — built up weight by weight, so it is the true maximum.