ZeroedStart a ledger

How to settle a group in the fewest payments

A group of n people can always settle every debt in at most n minus 1 payments, because once you know each person’s net position (what they paid minus their share), everyone who is owed money only needs to be paid by people who owe, and the last balance closes itself. Zeroed computes every member’s net position, sorts debtors and creditors from largest to smallest, and matches them greedily, which produces at most n minus 1 transfers and usually fewer.

Why do group debts feel bigger than they are?

Because people remember pairs. Tom paid for dinner, Priya paid for fuel, Jess paid the lodge, so Tom thinks he owes Jess, Priya thinks Tom owes her, and someone starts a spreadsheet with 12 arrows on it. None of those arrows matter. The only number that matters is each person’s net position.

What is a net position?

Net position is what you paid for the group minus your share of everything. Positive means the group owes you; negative means you owe the group. Across the whole group the net positions always add to zero, which is the property that makes settlement simple.

Why at most n minus 1 payments?

Every payment can be chosen to close at least one person’s balance completely: the smaller of the two balances involved goes to zero. With n people and balances that sum to zero, once n minus 1 balances are zero the last one must be zero too. So n minus 1 payments always suffice. Finding the absolute minimum below that is a hard problem in general (it is NP-hard), but the greedy method is within one or two of optimal for real groups and is what most tools, including Zeroed, use.

How does Zeroed choose who pays whom?

  1. Compute each member’s net position from the ledger, in whole cents.
  2. Sort people who owe from largest to smallest, and people who are owed the same way.
  3. Match the largest debtor with the largest creditor, transfer the smaller of the two balances, and move on whichever side hit zero.
  4. Repeat until every balance is zero.

Ties are broken deterministically so everyone’s phone shows the same plan.

Worked example

PersonPaidShareNet
Priya$920.00$366.13is owed $553.87
Tom$146.50$565.13owes $418.63
Jess$398.00$565.12owes $167.12
Marcus$0.00$366.12owes $366.12

Three debtors, one creditor, so three transfers: Tom pays Priya $418.63, Marcus pays Priya $366.12, Jess pays Priya $167.12. Cents that do not divide evenly are assigned one at a time so the ledger always balances to the cent.

Start a ledger

Questions

What is the minimum number of payments to settle a group?

Never more than the number of people minus one. Usually fewer, when several people are square or one person paid for most things.

Does the order of payments matter?

No. Each transfer in the plan is independent; do them in any order and everyone ends square.

Why does a split of $10 between three people give 3.33, 3.33 and 3.34?

Because cents are whole. The leftover cent goes to one person so the total is exact instead of a cent going missing.

More from Zeroed