0

split-payment

agent-skillstest-driven-development

Utility for splitting an amount of money among n participants without losing or inventing cents. Amounts are integer cents throughout; the library never touches floating point.

Sign in to save downloads to your library and vote.

Preview

split-payment

Utility for splitting an amount of money among n participants without losing or inventing cents. Amounts are integer cents throughout; the library never touches floating point.

API

splitCents(totalCents, n) returns an array of n integer cent amounts. totalCents is a non-negative integer, n is a positive integer.

Invariants

Every result must satisfy both invariants, for every input:

  1. Exactness — the shares sum to exactly totalCents. Money is never lost or created.
  2. Fairness — no two shares differ by more than one cent. When the total does not divide evenly, the leftover cents go to the earliest shares, one cent each.

For example, splitCents(100, 7) is [15, 15, 14, 14, 14, 14, 14].

Tests

npm test

Ingestion metadata

Source catalog
agent-skills
Repository
addyosmani/agent-skills · main
File path
evals/fixtures/test-driven-development/README.md
Last refreshed
10/24/2026, 3:00:12 AM (5h ago)
Refresh schedule
Daily · 03:00 UTC
Dedupe status
Unique · deduped by (source, url)