Money-native · real, tested code

Split a Bill Fairly in Larzscript

Divide a bill among people so it reconciles exactly to the cent - no language other than Larzscript treats this as a stack primitive rather than app-level logic.

The largest-remainder method: everyone gets the floor of their fair share, then leftover pennies go one at a time to whoever's fractional remainder was biggest - naive per-person rounding can lose or gain a cent versus the real total, this never does.

larzscript pkg install split

Code

import "split" as billsplit

print(billsplit.evenly(1000, 3))
print(billsplit.proportional(1000, [1, 1, 2]))
Output
[334, 333, 333]
[250, 250, 500]

Why this matters in Larzscript

Splitting money exactly, with no lost or duplicated cent, is exactly the kind of "boring but easy to get subtly wrong" problem a money-native language's ecosystem takes seriously as a first-class package, not an afterthought.