How the Greedy Debt Simplification Algorithm Works
When a group of friends travels together or shares apartment rent, individual members pay for different expenses at different times. One person might book the hotel room, another pays for fuel, and another covers dinner.
Calculating settlements manually often leads to messy circular transactions (e.g., A pays B, B pays C, and C pays A). Our Fair Share Calculator uses a greedy debt minimization algorithm:
It matches the largest debtor directly with the largest creditor. This cancels out intermediate debts, resolving the entire group in the mathematically minimal number of peer-to-peer transfers (at most $N - 1$ transfers for $N$ members).
Step-by-Step Settlement Case Study (4 Friends on a Weekend Trip)
| Friend | Expenses Covered | Amount Paid | Fair Share | Net Position |
|---|---|---|---|---|
| Rana | Resort Booking & Highway Fuel | ৳12,000 | ৳4,500 | +৳7,500 (Creditor) |
| Sabbir | Dinner & Barbecue Groceries | ৳4,500 | ৳4,500 | ৳0.00 (Even) |
| Tanvir | Highway Snacks & Drinks | ৳1,500 | ৳4,500 | -৳3,000 (Debtor) |
| Nafis | Did not pay upfront | ৳0 | ৳4,500 | -৳4,500 (Debtor) |
Where to Apply Fair Share Debt Optimization
Weekend Road Trips & Vacations
Avoid collecting cash for every highway toll or meal. Have different friends swipe their cards naturally throughout the trip, input the totals here at the end, and settle via bKash, Venmo, or bank transfer in two minutes.
Apartment Roommates & Shared Utilities
Reconcile monthly Wi-Fi, electricity, gas, cleaning supplies, and shared groceries without maintaining complex Excel spreadsheets or tracking overlapping debts.
Frequently Asked Questions (FAQ)
Why does the calculator recommend fewer transfers than people who owe money?
If Person A owes Person B $20, and Person B owes Person C $20, Person B shouldn't make a transfer at all. The algorithm instructs Person A to send $20 directly to Person C, cutting the number of transactions in half.
Is there any limit to the number of friends I can add?
No. You can add as many friends as needed for large tour groups, family reunions, or corporate offsites. The solver scales seamlessly across dozens of participants.
Is any financial data saved on a remote server?
No. All calculations run strictly in client-side memory using pure TypeScript. No names, amounts, or location details are ever logged or sent across any network.
