Welcome to the payouts utilities team. This module splits a total amount (integer cents) among n recipients as evenly as possible; remainder cents go to the earliest recipients so the parts sum exactly to the total.
Welcome to the payouts utilities team. This module splits a total amount (integer cents) among n recipients as evenly as possible; remainder cents go to the earliest recipients so the parts sum exactly to the total.
There is one ticket below. Fix as much of it as you can in 35 minutes. Each hidden check is graded separately, so partial progress still shows.
Splits do not add up to the total. The distribution step hands everyone the base amount and ignores the remainder, so cents go missing whenever the total does not divide evenly.
split_amount(100, 3) is [34, 33, 33].split_amount(10, 4) is [3, 3, 2, 2].split_amount(7, 2) is [4, 3].Keep the public function split_amount.
split.py (split_amount) and remainder.py (distribute, which hands out the base amounts plus the remainder). The shipped regression tests are in tests/visible/; every one of them fails until the bug is fixed.pytest tests/visible.Adapted from treasure567/bloomberg-practice (round-1/lumen @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
amount-split-remainder-cents
Changes under src/ are evaluated.