~learn.
0:00 / 1:07
LLD · Splitwise

Split ₹100 three ways. Where does the last paisa go?

transcript

Split 100 rupees between three friends. Your app just lost a paisa. And the group can never settle.

Round each share to 33 rupees 33 paise. Three of those make 99 rupees 99 paise. One paisa, gone. And floats make it worse. Balances that never quite reach zero.

So count in paise. 100 rupees is 10,000. Divide by three. 3,333 each, and 1 paisa left over. One person takes it. 3,334. Now it adds up exactly.

Each split strategy owns that job. Equal gives extra paise to the first few, sorted. Exact shares that don't add up? Refused. Percent floors every share. The leftover goes to the largest remainders. 50 and 40 percent? Rejected. Never quietly normalised.

Integer paise everywhere inside the system. Never floats. Rupees only on screen, and in the UPI link.

Now every balance sums to exactly zero. To the paisa. Every paisa goes to someone.

Full breakdown in the lecture.