BuildSeniorBackendAuto-graded
Fix a transfer that loses or invents money
Money handling demands discipline: exact arithmetic, no overdrafts, and nothing half-applied when a transfer is refused.ledger.py is a double-entry money ledger, and the version that shipped is dangerous. It does its arithmetic in floating point, so cents drift. It never checks for an overdraft, so a large transfer drives an account negative and invents money out of nothing. And it is not atomic: when the destination account is unknown it debits the source first and bails out afterwards, so money simply disappears. Make transfers exact, refuse the ones that should be refused, and ensure a refused transfer leaves nothing half-applied.40 min
python
You're done when
- Money is conserved — the total across all accounts is unchanged by any sequence of transfers.
- No account can be driven negative.
- A transfer larger than the available balance is rejected rather than silently allowed.
- A rejected transfer is atomic: it leaves no partial debit or credit behind.
- Self-transfers, unknown accounts and malformed amounts are rejected.
- Final balances are exact to the cent, with no floating-point drift.
What it measures
Back-end developmentHandling money with the discipline it demands — exact arithmetic, enforced invariants, and operations that either fully happen or fully do not.
Test case designFinding the inputs that break an invariant: the overdraft, the unknown counterparty, the self-transfer, the amount that does not round cleanly.
Reasoning about correctnessRecognising that conservation and atomicity are properties of the whole system, not of any single happy-path transfer.
Your environment
Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards
Start this lab
40 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo