No need to turn the camera on. Out of four questions, all subtasks passed on three of them.
I was just using it as practice — I didn't use AI, wrote all three questions myself. Level 1 and 2 were fairly simple.
Design Banking System
Level 3: Schedule Payments
-
transfer(timestamp, source_account_id, target_account_id, amount) -> str|None- At
timestamp, deductamountfromsource_account_idand freeze it temporarily until the target account accepts, or the transfer expires (auto-returned after 24h). - If
source_account_idandtarget_account_idare the same, either account doesn't exist, or the balance is insufficient, returnNoneimmediately. - A valid transfer returns a unique ID, like
"transfer1","transfer2". - Frozen funds count toward both accounts' "unsettled" transaction totals, and are only recorded into both sides' transaction histories once accepted.
- At
-
accept_transfer(timestamp, account_id, transfer_id) -> bool- At
timestamp, accept a previously initiated transfer:- Return
Trueif and only iftransfer_idexists, hasn't expired, hasn't already been accepted, andaccount_idis exactly the target account of that transfer. - Otherwise return
False(including cases where the transfer doesn't exist, has expired, has already been accepted, or the receiver doesn't match).
- Return
- At
Level 4: Account Merging and History Lookback
-
merge_accounts(timestamp, account_id_1, account_id_2) -> bool- At
timestamp, mergeaccount_id_2intoaccount_id_1:- If the two IDs are the same, or either doesn't exist, return
False. - Cancel (i.e. expire) all pending outgoing transfers from
account_id_2; also cancel all pending transfers fromaccount_id_1toaccount_id_2. - Redirect all other transfers destined for
account_id_2toaccount_id_1. account_id_1's balance increases byaccount_id_2's balance; transaction totals accumulate the history of both.- Finally, delete
account_id_2from the system and returnTrue.
- If the two IDs are the same, or either doesn't exist, return
- At
-
get_balance(timestamp, account_id, time_at) -> int|None- Query
account_id's balance right aftertime_at(including whatever operation had just finished processing at that moment):- If
account_idhadn't been created yet, or had already been deleted, attime_at, returnNone. - Otherwise return the correct historical balance value.
- If
- Query
Discussion
Loading comments…