Six friends rent a house for a week. Aisha pays the deposit. Mateo does the big supermarket run. Keiko buys the train tickets for four of them. Omar pays for two dinners, one of which Priya missed. By Friday there are twenty-three receipts and nobody can face the conversation.

Expense-splitting apps exist for this moment. What they do looks like magic and is in fact two small ideas, both of which you can carry out with a pencil.

Idea one: only the net matters

The instinct is to track who owes whom. Mateo owes Aisha for the deposit. Aisha owes Mateo for groceries. Keiko is owed by three people for tickets and owes two for dinner.

Written that way, six people can have up to fifteen separate two-way debts, and settling each one separately means a great many small transfers, several of which cancel each other out.

The first idea is to forget who owes whom and ask a different question about each person: across the whole week, did you pay more than your share, or less?

For each person, add up everything they paid. Then add up their share of every expense they took part in. The difference is their net balance.

Person Paid Fair share Net
Aisha 900 520 +380
Mateo 640 520 +120
Keiko 480 560 −80
Omar 500 520 −20
Priya 300 440 −140
Jamal 260 520 −260

(The amounts are invented, and in whatever currency you like.)

Two things to notice. The net column adds up to zero, as it always must, which is a useful check on your arithmetic. And all the complexity of twenty-three receipts has collapsed into six numbers. It no longer matters that Keiko's debt came from a dinner and Jamal's from the deposit. Money is money.

Unequal shares are handled at this stage and not later. Priya missed a dinner, so her fair share is lower. Someone who does not drink is left out of the wine. Get the shares right here and everything afterwards is mechanical.

Idea two: biggest pays biggest

Now there are two groups: people who are owed money, and people who owe it. Any set of payments that brings every balance to zero is a valid settlement. The question is how to do it in few payments.

A simple method works very well:

  1. Find the person who owes the most and the person who is owed the most.
  2. The first pays the second as much as possible: either the whole of what they owe, or the whole of what the other is owed, whichever is smaller.
  3. At least one of them is now at zero. Cross them off.
  4. Repeat until everyone is at zero.

With the table above:

  • Jamal owes 260 and Aisha is owed 380. Jamal pays Aisha 260. Jamal is settled; Aisha is still owed 120.
  • Priya owes 140 and Aisha and Mateo are each owed 120. Priya pays Aisha 120. Aisha is settled; Priya still owes 20.
  • Keiko owes 80 and Mateo is owed 120. Keiko pays Mateo 80. Keiko is settled; Mateo is owed 40.
  • Priya and Omar each owe 20. Each pays Mateo 20.

Five payments, and twenty-three receipts are finished with.

Each step settles at least one person completely, so a group of n people never needs more than n − 1 payments. Six people, five payments at most. That is the guarantee, and it holds however tangled the week was.

Can it be done in fewer?

Sometimes. If some subset of the group happens to balance exactly among themselves, say one person owed 100 and two people owing 50 each, that subset can be settled separately, and each such subset saves one payment.

Finding the true minimum means searching for those subsets, and that turns out to be a genuinely hard problem. It belongs to a family computer scientists call NP-hard, which roughly means that no known method is efficient for every case as the group grows. It is a close relative of a classic puzzle: given a list of numbers, is there a selection that adds up to exactly zero?

For a holiday with six friends this is of no practical importance. A phone can try every possibility in an instant, and the simple method above is usually within one payment of the best. It becomes interesting at the scale of banks, which settle obligations among thousands of institutions and use the same netting idea to shrink millions of transactions into a small number of transfers.

What the algorithm changes about who pays whom

There is a consequence that surprises people the first time. After netting, you may be asked to pay someone you never owed anything.

In the example Priya pays Aisha 120. Priya's debts might have come entirely from Omar's dinners and Keiko's tickets. The algorithm does not care. It has discovered that the group as a whole is square if Priya sends money to Aisha, and it is right.

Most people are content with this once it is explained. A few are not, particularly if they would rather not transfer money to a relative stranger in the group. A good app lets you choose between "fewest payments" and "only pay people you actually owe". The second gives more transfers and feels more natural. Neither is wrong.

Doing it without an app

For a single dinner, do not bother with any of this. For a week away:

  1. Keep every receipt in one place, with a name on it.
  2. For each one, note who took part.
  3. At the end, fill in the three columns: paid, fair share, net.
  4. Check that the nets add up to zero.
  5. Biggest debtor pays biggest creditor, until done.

It takes about fifteen minutes for a group of six, and it can be done at the kitchen table with everyone watching, which has a virtue no app can match: everybody sees the arithmetic and nobody has to trust it.

The maths was never the hard part of shared money. Agreeing what counts as a fair share is. But it helps to have the maths out of the way.