Blog
How kisir works out who pays whom
People ask how the settle-up screen decides who sends what to whom. The honest answer is short: add up everyone's balance, then repeatedly match the person owed the most with the person who owes the most. Here's the whole thing, with exact cents.
The part of kisir people are most curious about is the last one: the screen that says “you send Cleo €26.48” and nothing else. It looks like magic until you see it’s two small steps.
This is the “how we built it” version. If you want the practical how-to for settling a group yourself, the fewest transfers guide is the place for that.
The problem is capture, not math
The arithmetic of splitting costs is old and solved. The hard part is getting every expense into one place with the right people attached, so the app puts its effort there: several payers on one bill, any subset of the group, equal, shares or exact amounts.
Once the expenses are in, two small functions turn them into “pay this person this much.”
Step 1: one number per person
For every person, kisir works out a single figure: what they paid minus what they owe, across every expense in the group.
- Positive means the group owes them.
- Negative means they owe the group.
For each expense, the people who paid get credit for what they put in. Then everyone the expense was for gets charged their share. Equal means the total divided by the number of people. Shares means divided in proportion. Amounts means exactly what you typed.
Those balances always sum to exactly zero, because every euro someone paid is a euro someone else owes. That “exactly” is the point of the next section.
The leftover cent
Split €80.00 three ways and you get 26.666… Nobody can pay two-thirds of a cent, so someone has to take the extra.
Here is what we do. All the arithmetic is done in whole cents, never in decimals, because adding fractions of money in floating point quietly loses pennies. Then for an equal split:
- Divide the total in cents by the number of people, rounding down.
- Count the cents left over. That’s always fewer than the number of people.
- Give those leftover cents out one each, to people in a fixed order.
The fixed order matters. The same group always gets the same answer, so a number never shifts between two refreshes of the screen. And because the leftovers are handed out rather than rounded away, the shares add back to the total to the cent. Money is conserved. Nothing is created and nothing disappears.
Step 2: the fewest payments
Now we have, say, three people who are owed money and two who owe it. Who pays whom?
The method is greedy, and you can do it on paper:
- Take the person who is owed the most.
- Take the person who owes the most.
- The smaller of the two amounts moves from the debtor to the creditor. That’s one payment.
- At least one of them is now at zero. Put the other back with whatever remains.
- Repeat until everyone is at zero.
Every payment clears at least one person completely, and the last payment clears two. So with N people you can never need more than N − 1 payments. Eight friends: at most seven. Five flatmates: at most four. That’s a ceiling. Often it’s fewer.
One worked example
Say five flatmates share a weekend: Ana, Ben, Cleo, Dan and Eli, in euros. This is a made-up weekend, but the cents are exact.
| Expense | Paid by | Amount | Split equally between |
|---|---|---|---|
| Groceries | Ana | €83.47 | all 5 |
| Fuel | Ben | €60.00 | Ana, Ben, Cleo, Dan |
| Dinner | Cleo | €112.30 | all 5 |
| Boat | Dan | €95.00 | Cleo, Dan, Eli |
| Museum tickets | Eli | €41.00 | Ana, Ben, Eli |
The total is €391.77. Now the shares, in cents, with leftover cents handed out in the order Ana, Ben, Cleo, Dan, Eli:
- Groceries, 8,347 ÷ 5 is 1,669 each with 2 left over. Ana and Ben pay 1,670. Cleo, Dan and Eli pay 1,669.
- Fuel, 6,000 ÷ 4 is 1,500 each. Nothing left over.
- Dinner, 11,230 ÷ 5 is 2,246 each. Nothing left over.
- Boat, 9,500 ÷ 3 is 3,166 with 2 left over. Cleo and Dan pay 3,167. Eli pays 3,166.
- Museum, 4,100 ÷ 3 is 1,366 with 2 left over. Ana and Ben pay 1,367. Eli pays 1,366.
Each person’s total owed, and the balance:
| Paid | Owes | Balance | |
|---|---|---|---|
| Ana | €83.47 | €67.83 | +€15.64 |
| Ben | €60.00 | €67.83 | −€7.83 |
| Cleo | €112.30 | €85.82 | +€26.48 |
| Dan | €95.00 | €85.82 | +€9.18 |
| Eli | €41.00 | €84.47 | −€43.47 |
Check it: paid and owed both add up to €391.77, and the balances add up to zero: 15.64 + 26.48 + 9.18 = 51.30, and 7.83 + 43.47 = 51.30.
Now the match.
- Cleo is owed the most (€26.48), and Eli owes the most (€43.47). Eli sends Cleo €26.48. Cleo is done. Eli still owes €16.99.
- Ana is next (€15.64). Eli sends Ana €15.64. Ana is done. Eli still owes €1.35.
- Dan is owed €9.18. Eli sends Dan €1.35. Eli is done. Dan is still owed €7.83.
- Ben owes exactly €7.83. Ben sends Dan €7.83. Everyone is at zero.
How it ends
Four payments for five people, the ceiling. The total moved is €51.30, which is exactly what the creditors were owed. Without netting, you would be paying back five separate expenses, person by person.
Why we didn’t chase the perfect answer
Greedy is not always the absolute fewest. Finding the true minimum number of payments for any group is a famously hard problem (it’s NP-hard, if you like the jargon). In rare cases there’s a clever grouping of debts that saves one payment over the greedy match.
We looked at that and decided not to build it. Reasons:
- The gain is tiny. The greedy result is already at most N − 1, and groups of friends are small. The perfect version might save a payment in the odd case.
- The cost is not tiny. More code, and harder to explain.
- Predictable beats clever. You can check the greedy answer with a pencil. If the screen says Eli pays Cleo first because Cleo is owed the most, that’s something a person can see for themselves. Trust is the product here.
Our own plan says it plainly: don’t over-engineer this part. I still agree.
What you see in the app
Open the overview and you get your balance (“You’re owed” or “You owe”) and everyone else’s. Your plan is your part of the settlement: the payments you send or receive. Record each one as it happens, and when every balance reaches zero the group closes itself. If you add an expense afterwards, it asks before re-opening.
If your trip mixes currencies, kisir converts each expense into the group’s currency first, using the rate you set, and then runs the same two steps. The multi-currency guide covers that part.
For doing it by hand with no app at all, the group trip guide walks through the method end to end.
Want to see it on your own group?
Make a group, add a few expenses, and open Your plan. No account, no ads, free.
Get kisir