Level 1 Accounts and money
Build Bank. Every method takes a timestamp (an integer, milliseconds) first. Timestamps strictly increase from one call to the next. Amounts are positive integers.
create_account(timestamp, account_id) -> bool: open an account with balance 0.Falseif an account with that id already exists.deposit(timestamp, account_id, amount) -> int | None: add money and return the new balance.Noneif the account doesn't exist.withdraw(timestamp, account_id, amount) -> int | None: take money out and return the new balance.None(changing nothing) if the account doesn't exist or has less thanamount.transfer(timestamp, source_id, target_id, amount) -> int | None: move money right away and return the source's new balance.None(changing nothing) if either account doesn't exist, they're the same account, or the source has less thanamount.
bank = Bank()
bank.create_account(1, "a"); bank.create_account(2, "b")
bank.deposit(3, "a", 500) # 500
bank.withdraw(4, "a", 100) # 400
bank.transfer(5, "a", "b", 150) # 250
bank.transfer(6, "b", "a", 999) # None