How debt simplification works
Five friends share a weekend away and end up with ten debts between them. Three payments clear the lot. Here’s the math behind the fewest payments, worked through with the same code Potluck runs.
The example
Five friends rent a cabin for a weekend. Four things get bought, each split evenly between all five, and Eli hasn’t paid for anything yet. That’s $1,000 in all, or $200 each.
| Friend | Paid | Their share | Balance |
|---|---|---|---|
| Ana | $500 | $200 | +$300 |
| Ben | $150 | $200 | −$50 |
| Cleo | $250 | $200 | +$50 |
| Dev | $100 | $200 | −$100 |
| Eli | $0 | $200 | −$200 |
Step one: everyone’s balance
Each person’s balance is what they paid minus their share of everything. Positive means they’re owed money, negative means they owe it. Add up the balances and you always get zero: every dollar someone is owed, someone else owes. That’s the only thing simplifying needs to know. It doesn’t matter who paid for what, or how each thing was split.
Without simplifying: each pair settles up
The obvious way is for each pair to work out what’s between them and settle it. If Ben owes Ana for the cabin and Ana owes Ben for the groceries, they net it out into one payment. With five people there are ten pairs, and here every one of them ends up owing something: ten payments, $460 sent in all.
- Ben pays Ana $70
- Cleo pays Ana $50
- Dev pays Ana $80
- Eli pays Ana $100
- Ben pays Cleo $20
- Dev pays Ben $10
- Eli pays Ben $30
- Dev pays Cleo $30
- Eli pays Cleo $50
- Eli pays Dev $20
That grows fast. Ten people have forty-five pairs, and on a long trip plenty of them will owe each other something.
Step two: the biggest debt pays the biggest credit
Simplifying ignores who owed whom and works from the balances alone. Potluck takes the person who owes the most and has them pay the person who’s owed the most, as much as the smaller of the two. One of them is now square. Then it does it again, until everyone is. When two people owe or are owed the same, whoever joined the potluck first goes first, so every phone works out the same payments.
- Eli owes the most ($200) and Ana is owed the most ($300). Eli pays Ana $200. Eli is square; Ana is owed $100.
- Dev owes the most ($100) and Ana is owed the most ($100). Dev pays Ana $100. That squares them both.
- Ben owes the most ($50) and Cleo is owed the most ($50). Ben pays Cleo $50. That squares them both.
Three payments instead of ten, and everyone ends up exactly where their balance said.
Why it never takes more than one fewer than the people
Every payment squares at least one person, and the last one squares the final two at once. So five people never need more than four payments, and ten never more than nine. Here it took three, because step two squared Dev and Ana at once.
It sends the least money, too
Every payment goes from someone who owes to someone who’s owed, never through someone in the middle. So the total sent is exactly what’s owed: $350, against $460 when each pair settles up. No set of payments can send less, because everyone who’s owed has to receive at least their balance.
Is it always the fewest payments? No
It usually is, but not always, and it’s worth being straight about. Say five people’s balances come out like this: Ana is owed $60, Ben is owed $40, Cleo owes $40, Dev owes $30 and Eli owes $30. Biggest debt to biggest credit takes four payments:
- Cleo pays Ana $40
- Dev pays Ben $30
- Eli pays Ana $20
- Eli pays Ben $10
But three will do:
- Cleo pays Ben $40
- Dev pays Ana $30
- Eli pays Ana $30
The shorter answer spots that Cleo and Ben cancel out exactly, and so do the other three. Finding groups like that means trying every way of splitting the people into groups whose balances add up to zero, and the number of ways explodes as the group grows. Computer scientists have shown that finding the true minimum is NP-hard: no known method does it quickly for every group.
Why Potluck uses it anyway
- It keeps payments few. Never more than one fewer than the number of people, usually the fewest possible, and never a cent more sent than is owed.
- It’s the same everywhere. Your phone, your friends’ phones and Potluck’s server run the same code, with ties broken by who joined first, so everyone sees the same payments.
- It adds up to the cent. Every amount is a whole number of cents, so the payments always square everyone exactly, with no stray fractions.
- It’s instant. It works out a potluck of any size as you add expenses.
The one catch
Simplified, someone can end up paying a person they didn’t owe directly. The totals stay the same: nobody pays a cent more or less than their balance. If your group would rather each pair settled their own, turn off Simplify payments in the potluck’s settings. It’s on to start with. To try it on your own numbers, the who owes whom calculator shows the fewest payments as you type.
Questions
What is debt simplification?
Working out the fewest payments that settle a group’s debts. Instead of everyone paying back each person they owe, the group’s debts are added up into one balance per person, and the people who owe pay the people who are owed directly.
Does simplifying change how much anyone pays?
No. Everyone pays, or gets back, exactly their balance: what they paid minus their share of everything. Only who pays whom changes.
Why am I paying someone I didn’t owe?
Because money doesn’t have to go back the way it came. If you owe Ana and Ana owes Ben, paying Ben directly settles both debts in one payment. Your total is the same either way.
Is it always the fewest payments possible?
Not always. Potluck matches the person who owes the most with the person who’s owed the most, again and again. That never takes more than one payment fewer than the number of people, and it moves the least money possible, but now and then a cleverer set of payments needs fewer. Finding the true minimum every time is a much harder problem.
How many payments will it take?
At most one fewer than the number of people who owe or are owed something. Five people take four payments at most, ten take nine. Often fewer, when some people’s balances cancel out among themselves.
Can I turn it off?
Yes. Turn off Simplify payments in the potluck’s settings, and each pair settles what’s between them instead. It takes more payments, but nobody pays someone they didn’t owe directly.
Does it work when things weren’t split evenly?
Yes. Simplifying only looks at each person’s balance, so it doesn’t matter how each expense was split: equally, between some people, by exact amounts, by percentages or by shares.