Learn / System Design
Module 09 · System Design · The low-level design round
Continue where you left off ×
Who owes whom (design Splitwise)
Who Owes Whom · Open board
Paise not decimals, three splits behind one call, five balances that add to zero, and 9 payments cut to 4.
Before you start. Five short recaps.
The idea in 30 seconds
Money is whole paise in integers, because decimals drift.
An expense is who paid, how much, and each person’s share, and the shares add up to the total.
Equal, exact and percentage splits are three strategies behind one call.
A balance is paid minus owed, worked out from the ledger, and all balances add up to zero.
Settling up is one more line in the ledger.
Greedy debt simplification cut 9 payments to 4 on the trip. It is a good heuristic, not guaranteed to be the fewest.
Read the story
Lesson 44 of 73 in System Design
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year , or $19.50 for your first year with LAUNCH50 , ends 1 Nov, 18:30 UTC .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson February 2011: a rent calculator that grew Money first: whole paise, never decimals Expense: one payment, and who owes a share of it Balance: one number per person Settle up: a payment is just another line Debt simplification: fewer payments for the same result An honest warning: greedy is good, not perfect Terms it explains: invariant, strategy, ledger, class, low-level design round, integer, expense, balance, settle up, debt simplification, heuristic, paise, split strategy.
Review System Design
Mark as read Saved in this browser, and to your account when you sign in.