🧭 Do not search for the first 15 minutes. When stuck: re-read the requirements → define I/O → choose the data structure → trace a small example by hand → write code.
Implement reconcile(a, b), which compares the transaction records two systems kept
independently and classifies only the discrepancies, in three categories.
Both arguments are lists of (transaction id, amount) tuples.
system_a = [("T1", 100), ("T2", 200), ("T3", 300)]
system_b = [("T2", 200), ("T3", 250), ("T4", 400)]
Return a dictionary with three keys.
{
"missing_in_b": ["T1"], # ids only in a
"missing_in_a": ["T4"], # ids only in b
"amount_mismatch": [("T3", 300, 250)], # present in both, amounts differ
}
amount_mismatch tuple is ordered (id, a's amount, b's amount).All three lists keep their order of first appearance in the source.
missing_in_b and amount_mismatch → order of first appearance in amissing_in_a → order of first appearance in bDo not sort — reconciliation reports are read in ledger order by convention.
Implement reconcile(a, b). The rules and output shape match the shared spec.