10 lines
300 B
Python
10 lines
300 B
Python
"""Split a bill between payers. See SPEC.md for the rules."""
|
|
|
|
|
|
def split_cents(total, n):
|
|
if n < 1:
|
|
raise ValueError("need at least one payer")
|
|
share = round(total / n)
|
|
shares = [share] * n
|
|
shares[-1] += total - share * n # last payer absorbs the rounding
|
|
return shares
|