How settle up works

After a trip or a month in a shared house, everyone has paid for different things. Settling up means working out a list of payments that leaves everyone even. You could have everyone pay back every single expense, but that’s a lot of transfers. split finds the shortest list it can.

Step 1: balances

For each person, split adds up what they paid and subtracts their share of everything. A positive balance means the group owes them money; a negative one means they owe the group. All the balances always add up to exactly zero.

Step 2: the fewest payments

Say the balances are: Ana +£60, Ben +£20, Cy −£50, Dee −£30. A straightforward plan pays off the biggest debt to the biggest creditor first:

Three payments for four people. With n people who aren’t already even, you never need more than n − 1 payments, and this method always stays within that.

When you can do better

Sometimes a group splits into smaller groups that already cancel out. Take Ana +£40, Ben +£25, Cy −£25, Dee −£40. The obvious pairing works: Dee pays Ana £40 and Cy pays Ben £25. That’s two payments, not three, because {Ana, Dee} and {Ben, Cy} each add up to zero on their own.

The rule is: fewest payments = people with a balance − the most separate groups that each add up to zero. Each such group needs one fewer payment than it has people.

Finding those groups is a hard search problem in general, because the number of ways to split people into groups grows very fast. For groups of up to 16 people with open balances, split checks every combination, so the plan you see uses the fewest possible payments. Bigger groups use the step-by-step method above, which is still at most n − 1 payments.

Pennies and currencies

split does arithmetic, not financial advice. Check amounts before you send money.

Try it with your group

Free, no sign-up. Takes about 20 seconds.

Start a group