ICA-style · 4 levels · ~90 min · no AI
Bank ledger
Deposits, withdrawals and transfers → top spenders → scheduled transfers and cancelling → merging accounts and past balances. Four levels, each built on the last.
Build an in-memory bank ledger: class Ledger in src/ledger.py. Every method takes a timestamp first, an integer that strictly increases from one call to the next. Amounts are positive integers; account ids are non-empty strings.
| Method | Returns |
|---|---|
open_account(timestamp, account_id) | True after opening a new account with balance 0; False if the id is taken |
deposit(timestamp, account_id, amount) | the new balance; None if the account does not exist |
withdraw(timestamp, account_id, amount) | the new balance; None if the account does not exist or holds less than amount |
transfer(timestamp, source_id, target_id, amount) | the source's new balance; None if either account is missing, both ids are the same, or the source holds less than amount |
A call that returns None or False changes nothing.
The public tests of this level are tests/test_level1.py; the judge also runs hidden tests. Pass them all to unlock level 2. Leave the later levels' methods in the class: their briefs come with them.
Sign in to run the tests; passing a level unlocks the next.