Fix the even split for payments and refunds

Review the AI's codeEasy10 minStripe and PayPal style

Your task

Your payments service splits an amount across several payees, and the shares must always add up to the total. Amounts are in minor units (cents), so no floating point touches them. A refund is the same split with a negative total, and it must mirror the original payment exactly, payee by payee.

An assistant wrote allocate_amount_evenly(total_minor_units, payee_count). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • total_minor_units: the amount to split, in cents. Negative for a refund.
  • payee_count: how many payees share it.
  • Return each payee's share, in payee order.

Rules the tests check:

  • If payee_count is 0 or less, return [].
  • Split the size of the total, ignoring its sign: every payee gets that size divided by payee_count, rounded down. The leftover cents go one each to the first payees in order.
  • Then give every share the total's sign. So a refund of -100 cents splits as the negative of the payment of 100 cents.

Examples

allocate_amount_evenly(total_minor_units: int, payee_count: int) -> list[int]
Example 1
Inputallocate_amount_evenly(10000, 3)
Output[3334, 3333, 3333]
Example 2
Inputallocate_amount_evenly(100, 3)
Output[34, 33, 33]
Example 3
Inputallocate_amount_evenly(7, 7)
Output[1, 1, 1, 1, 1, 1, 1]