Expense splitter for a group trip
beginner1 to 2 weeksReactTypeScript
Add people and expenses, then see who owes whom with the fewest payments.
Why build it
The settle-up algorithm is a real problem with a clean solution, and money maths teaches you why floats are a trap.
Features
- Add people and shared expenses
- Equal or custom split per expense
- Running balance per person
- Minimal settle-up suggestions
- Export a summary as text
Roadmap
- p1
Model money safely
- Store amounts as integer cents
- Write split functions for equal and custom shares
- Handle remainders so totals always add up
- p2
Balances
- Compute net balance per person
- Test with 3 to 6 people and uneven splits
- p3
Settle-up
- Greedy match of biggest debtor to biggest creditor
- Show the resulting payment list
- Verify total paid equals total owed
- p4
UI and ship
- Expense form with validation
- Copy-to-clipboard summary
- Deploy and document the algorithm in the README
Common pitfalls
- Using floating-point dollars, which leaves 1-cent errors
- Forgetting to distribute the remainder cent when splitting evenly
Skills you will practise
- Integer money handling
- Greedy algorithms
- Form validation