I'm sure this has been asked before, but I tried searching and couldn't find it. I don't know the solution, and it is possible there isn't one.

There is unsavoury pirate and an unscrupulous merchant. The Pirate would like to trade some of his ill-begotten treasure for some shady merchandise. However, neither the pirate nor the merchant are trust-worthy. Given the chance, they would like to get what the other is offering without giving up anything. They will lie and cheat if necessary, and may even resort to the use of force if they think they can get away with it.

There are no third parties that they can turn to.

Is there a process by which they can exchange their articles in such a way that guarantees that no one will get taken advantage of?

I've been thinking of solution involving cryptography algorithms, but I am open to anything that seems plausible.

  • $\begingroup$ Do they agree on the real value of these kinds of goods? $\endgroup$ – Nautilus Jul 18 '19 at 17:34
  • $\begingroup$ @Nautilus Yes. We can assume that the bargaining is done already and that they are both satisfied with the trade. However, if they can have their cake and eat it too, they will do so. $\endgroup$ – Trenin Jul 18 '19 at 17:43
  • $\begingroup$ It seems that any solution involving physical proximity of the pirate and merchant could result in one of the parties just shooting the other, or taking them hostage until they surrender the goods. Do they have ranged weapons? $\endgroup$ – Nuclear Hoagie Jul 18 '19 at 18:00
  • $\begingroup$ Based on all the different answers making different assumptions about what is allowed and what isn't, and the unclear conditions on the problem, I've put this question as on hold as being not fully defined. $\endgroup$ – Deusovi Jul 18 '19 at 18:07

There are three necessary assumptions here:

(1) It is possible to build a physical mechanism that neither one of them can break.

If this were not the case, the only way trades could be made is by one person directly giving an item to the other. However, just giving items back and forth doesn't work: as soon as there's an imbalance in the wealth gained, the person with more can grab everything and run away. So there must be someone or something else involved: under the condition that no other person is involved, this assumption is necessary.

(2) All items in this deal are verifiable visually to not be fakes, without physically touching them.

If this were not the case, during the necessary physical inspection, one of them could run off with the item being inspected. So this assumption is also necessary.

(3) Neither one of them can coerce the other into giving up an object if they do not want to give up that object.

If this were not the case, either one could just extort the other, without having to give up anything in return. So this assumption is once again necessary.

Under these three assumptions, there is a mechanism that allows for perfect security in trades. The mechanism should be built into a large wall, so that the two people taking part in the trade are separated. It consists of:

  • Two compartments with trapdoors under them, the contents of which are visible to both participants. Each compartment has an opening to one side, and is tall enough so that items cannot be directly taken out of it from that opening.
  • A chute under each trapdoor leading to the same side the hole on the top is. This chute's bottom can also open like a trapdoor.
  • A second chute, under each of the first chutes, this time leading to the opposite side.
  • A "drop" lever on each side. If this lever is pulled, the first trap doors open, and all items in both compartments go back to the sides they came from.
  • An "accept" lever on each side. If both accept levers are being pulled, the chutes' bottoms open.

Both people involved can visually inspect the items being traded. If either one is unsatisfied, they pull the "drop" lever, and both sets of items are returned to their original owners. If both are satisfied, they both pull their "accept" levers, and then one pulls the "drop" lever, and the trade occurs.

This device is not just theoretical, though: it has been implemented to solve exactly this problem... in Minecraft. YouTuber SethBling made a trading system that solves this problem with a mechanism similar to the one I describe here.

| improve this answer | |
  • $\begingroup$ +1 I like the Minecraft use. Not exactly what I was looking for, but pretty good. $\endgroup$ – Trenin Jul 18 '19 at 17:35
  • $\begingroup$ +1 as I had the same idea. But visual inspection is not the same as handling it. Assuming the trader obtains the merchandise in exchange for gold coins, he could've simply either painted gold over bronze coins or coated with actual gold, to ensure a safe time to move away from the scene. $\endgroup$ – Abbas Aug 9 '19 at 11:28

The pirate and the merchant could meet in a large, open field, stand about 10 paces apart, and face each other, the pirate facing southeast and the merchant facing northwest. Their vessels would need to be moored or parked in the direction to their rear. Here is an example graphic: Pirate Merchant Handoff Graphic

  1. On cue, the pirate would walk due South 10 paces while the merchant would walk due North 10 paces.
  2. Then, on cue, the pirate would turn and walk due East 10 paces while the merchant walks due West 10 paces. At this point, both would set their loot down.
  3. Now, on cue, the pirate walks 10 paces due North while the merchant walks due South.
  4. Lastly, on cue, the pirate finishes by walking the 10 paces due West and the merchant walks due East.

They would now be in possession of each other's loot and be near their starting points and vessel/boat/etc.

My reasoning:

  • At any point, they can clearly see if the other is committed to the steps.
  • During step 1, if either decides to attack/rob the other, they are too far away, allowing the other to escape to their vehicle with their own ware.
  • During step 2 and 3, if either decides to attack/rob, the other is close to their enemy's vehicle, a mutual disadvantage for both. They are also in possession of or closer to their own loot.
  • During step 4, if either decides to attack/rob the other, the potential victim can simply run, grab the traded loot, and escape in their own vehicle/vessel.

I don't imply that this is the perfect solution, but it requires no additional people or resources, other than a compass.

| improve this answer | |
  • 1
    $\begingroup$ I really like this idea. A few issues I have: it requires that the Merchant and Pirate be of similar physical condition. The Merchant in a wheel chair might not fair well in this exchange. Likewise, nothing stops the pirate from taking the Merchant's loot and running directly back to his own ship and killing the Merchant and taking back his treasure if he thinks he can get away with it. $\endgroup$ – Trenin Jul 18 '19 at 17:41
  • $\begingroup$ Good point @Trenin. $\endgroup$ – alondo Jul 18 '19 at 17:46

They could:

Set up a vault that requires a key (or passcode, or whatever) from each of them to open. Within the vault there are two subvaults, one only accessible to the Merchant and one only accessible to the Pirate.

Before each deal:

They each witness the other seal away wealth exceeding what's at stake in the deal, then exit and lock the vault. They then proceed with their business, with the ultimatum that they will only unlock the outer vault once they have received their end of the bargain. Assuming they place little value in denying funds to the other without personally profiting, it remains in both of their best interests to hold up their end of the deal.

| improve this answer | |
  • $\begingroup$ This requires that each have something worth more than the current trade that can be held ransom. I like the idea though. $\endgroup$ – Trenin Jul 18 '19 at 17:38

Find a narrow ravine and have one person stand on either side with the goods to be traded. Suspend a log over the ravine from a single rope in the center, so that it can spin freely and one end can be reached by either party. To start, each end of the log is firmly fixed to the ground on either side, so neither party can spin the log until both release it. Each party ties their goods to one end of the log, and once both can see the other party has done so, they both release the log, and spin it so that they now have access to the opposite end of the log with their trading partner's goods. The log only spins when both parties let it, and no one ever has access to both sets of goods at the same time.

This solution requires that both parties can verify that the other party has indeed put up their end of the bargain by tying it to the end of the log, and can do so from the other side of the ravine.

| improve this answer | |
  • $\begingroup$ I like this. It needs a bit more work though to flesh it out. What is to stop the Pirate from waiting for the merchant to tie his goods and then forcibly spinning the log before tying his own? If he is stronger than the merchant, this is likely. $\endgroup$ – Trenin Jul 18 '19 at 17:47
  • $\begingroup$ @Trenin Added an additional step - just fix the log at both ends so that any movement requires both parties to release the log. $\endgroup$ – Nuclear Hoagie Jul 18 '19 at 17:49


Exchange their treasures one coin/gem at a time - this way, any losses are minimized.


We wish to swap the values of P and M without either ever having more than the other (and thus running off with all the loot!). This is IMPOSSIBLE - the only swap routines using only two variables invariably create the scenario with one variable greater than the other. For example, the XOR swap algorithm.

| improve this answer | |
  • $\begingroup$ Interesting idea, but I am looking to guarantee the exchange, not minimise the loss. $\endgroup$ – Trenin Jul 18 '19 at 15:51
  • $\begingroup$ Wasn't looking for exchange of information, but rather exchange of ownership. XOR swap doesn't work with physical things. $\endgroup$ – Trenin Jul 18 '19 at 17:39

The main idea (trivial but still):

They should offer checks and balances against each other. If the pirate cheats, the merchant must have a chance to take back the excess value later and vice versa. Same goes for the merchant asking for too much in return, the pirate's counter-request, and so on. Rinse and repeat, and the deal won't be completed until no one cheats the other.

An idea how to do that:

They go to a room split into two by a durable, thick wall with bulletproof glass, and put their money and valuables into a double-sided safe that's too heavy to move around in the gap in the middle of the wall. Then they take what's worth, but if they take too much, the other will move to the safe and take some. The room has some sort of a mechanism preventing both from escaping unless both give up on taking more (by staying away from the safe) for over a certain time period.

| improve this answer | |
  • $\begingroup$ And how do you propose that they do this? $\endgroup$ – Deusovi Jul 18 '19 at 17:44
  • $\begingroup$ Elaborate. What stops the Merchant from pulling back excess after the trade, thus cheating the Pirate? $\endgroup$ – Trenin Jul 18 '19 at 17:44
  • $\begingroup$ Edited my answer and added a scenario about how to do it. $\endgroup$ – Nautilus Jul 18 '19 at 18:57

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