Debt Simplification Algorithm Explained — How Niptao Minimises UPI Transfers
What is debt simplification and how does it work? A complete technical explanation of how Niptao's algorithm minimises group debt transfers — with step-by-step examples using real INR amounts.
You're back from a 5-day Goa trip. There were 35 shared expenses. Everyone paid for different things at different times. Now it's settlement time and you're staring at a web of debts that looks like a spider had a breakdown.
Settling naively — everyone pays everyone they owe — could mean 15+ UPI transfers. But there's a smarter way. It's called debt simplification, and it's the algorithm that powers Niptao's settlement screen.
Here's exactly how it works.

The Problem: Many Expenses, Messy Debt Web
Let's use a concrete example. Four friends — Rahul, Priya, Ananya, and Vikram — just returned from a Goa trip. Here's what happened:
- Rahul paid for dinner (₹3,200) → split 4 ways → others each owe him ₹800
- Priya paid for the hotel (₹4,800) → split 4 ways → others each owe her ₹1,200
- Ananya paid for scooters (₹2,400) → split 4 ways → others each owe her ₹600
- Vikram paid for the ferry + beach activities (₹6,000) → split 4 ways → others each owe him ₹1,500
The raw debt picture (who owes whom):
| Who Owes | To Whom | Amount |
|---|---|---|
| Priya | Rahul | ₹800 |
| Ananya | Rahul | ₹800 |
| Vikram | Rahul | ₹800 |
| Rahul | Priya | ₹1,200 |
| Ananya | Priya | ₹1,200 |
| Vikram | Priya | ₹1,200 |
| Rahul | Ananya | ₹600 |
| Priya | Ananya | ₹600 |
| Vikram | Ananya | ₹600 |
| Rahul | Vikram | ₹1,500 |
| Priya | Vikram | ₹1,500 |
| Ananya | Vikram | ₹1,500 |
Naive settlement: 12 UPI transfers. No one has time for that.
Debt simplification reduces this to 3 UPI transfers and achieves the same financial result.
The Algorithm: Three Steps
Step 1: Calculate Each Person's Net Balance
Add up everything each person is owed, subtract everything they owe. The result is their net balance.
Rahul:
- Paid: ₹3,200 (dinner)
- His share: ₹800 (dinner) + ₹1,200 (hotel) + ₹600 (scooters) + ₹1,500 (activities) = ₹4,100
- Net: ₹3,200 - ₹4,100 = -₹900 (owes ₹900)
Priya:
- Paid: ₹4,800 (hotel)
- Her share: ₹800 + ₹1,200 + ₹600 + ₹1,500 = ₹4,100
- Net: ₹4,800 - ₹4,100 = +₹700 (is owed ₹700)
Ananya:
- Paid: ₹2,400 (scooters)
- Her share: ₹800 + ₹1,200 + ₹600 + ₹1,500 = ₹4,100
- Net: ₹2,400 - ₹4,100 = -₹1,700 (owes ₹1,700)
Vikram:
- Paid: ₹6,000 (ferry + activities)
- His share: ₹800 + ₹1,200 + ₹600 + ₹1,500 = ₹4,100
- Net: ₹6,000 - ₹4,100 = +₹1,900 (is owed ₹1,900)
Verification: -₹900 - ₹1,700 + ₹700 + ₹1,900 = 0 ✓ (Net balance of the group must be zero)
Step 2: Separate Into Creditors and Debtors
Creditors (net positive — they're owed money):
- Vikram: +₹1,900
- Priya: +₹700
Debtors (net negative — they owe money):
- Ananya: -₹1,700
- Rahul: -₹900
Step 3: Greedily Match Debtors to Creditors
The algorithm takes the largest debtor and the largest creditor, matches them, and settles as much as possible in one transfer.
Round 1:
- Largest debtor: Ananya (-₹1,700)
- Largest creditor: Vikram (+₹1,900)
- Transfer: Ananya pays Vikram ₹1,700
- After: Ananya is settled (₹0). Vikram now owed ₹200 (+₹1,900 - ₹1,700).
Round 2:
- Remaining debtor: Rahul (-₹900)
- Creditors remaining: Vikram (+₹200), Priya (+₹700)
- Largest creditor: Priya (+₹700)
- Transfer: Rahul pays Priya ₹700
- After: Priya is settled (₹0). Rahul still owes ₹200 (-₹900 + ₹700).
Round 3:
- Remaining debtor: Rahul (-₹200)
- Remaining creditor: Vikram (+₹200)
- Transfer: Rahul pays Vikram ₹200
- After: Everyone is settled.
Final settlement plan:
- Ananya pays Vikram ₹1,700
- Rahul pays Priya ₹700
- Rahul pays Vikram ₹200
3 UPI transfers instead of 12. Same financial result.

The Mathematics Behind It
Debt simplification is a form of the "minimum number of transactions to settle debts" problem in computer science. The greedy approach (always match the largest debtor with the largest creditor) produces optimal or near-optimal results for practical group sizes.
For groups of 2–20 people (the typical range for Indian friend groups, flatmates, and office teams), the greedy algorithm always performs excellently. For very large groups, more complex algorithms exist, but they're unnecessary for the use cases Niptao handles.
Key insight: What matters for settlement is not who owes whom specifically, but each person's net position. Two people can indirectly "cancel" each other's debts through the network without ever transacting directly.
Why This Matters for Indian Groups
Every extra UPI transfer has real friction costs in Indian group contexts:
- Someone must initiate the payment
- The recipient must confirm receipt
- Someone must mark it settled in the app
- If a payment is missed, follow-up is needed
The difference in real groups:
| Group Type | Naive Transfers | After Debt Simplification |
|---|---|---|
| 4-person weekend trip | 12 transfers | 3 transfers |
| 6-person Goa trip | 30 transfers | 4–5 transfers |
| 4-person flatmate group (1 month) | 12 transfers | 2–3 transfers |
| 10-person office team event | 90 transfers | 7–9 transfers |
| 8-person bachelor trip | 56 transfers | 6–7 transfers |
The reduction is dramatic. For a 6-person group, debt simplification cuts the settlement effort by 80–85%.
The One Limitation Worth Knowing
Debt simplification is mathematically optimal (minimum transfers) but doesn't always reflect "who actually owes whom" from the trip's perspective.
Example: Ananya might have never directly shared an expense with Vikram — but the algorithm says "Ananya pays Vikram ₹1,700." This is mathematically correct but can feel counterintuitive.
In practice: This is never a real problem. The financial outcome is identical. If Ananya pays Vikram ₹1,700, and Vikram owed Priya ₹700 which Ananya's payment now covers — everything nets out correctly.
The only time this creates genuine friction is if someone in the group doesn't trust the algorithm. In that case, show them the net balance for each person — the algorithm preserves those precisely.
How Niptao Presents the Settlement
When you tap "Settle Up" in Niptao, you see:
- Net balance for each member — who's overall in credit and who's in debit
- Settlement plan — a numbered list of "Person A pays Person B ₹X" instructions
- UPI action — a prompt to initiate each transfer
The algorithm runs automatically on every expense you log. You never have to think about it — you just see the clean, minimal result.
![]()
TL;DR
Debt simplification works in three steps:
- Calculate each person's net balance (what they paid minus what they owe)
- Separate people into creditors (owed money) and debtors (owe money)
- Match the largest debtor to the largest creditor, repeat until everyone is settled
For a 6-person trip, this typically reduces 30 potential UPI transfers to 4–5. Niptao does this automatically, every time, so you can focus on the trip instead of the maths.
Ready to niptao karo? Create a free group on Niptao and settle via UPI in seconds.
Ready to try Niptao?
Free bill splitting with UPI settlement. No credit card needed.
Get started free →