Python · Intermediate · 45 min

Reconcile account balances across formats

Compare normalized records, not aggregate totals.

Task

Implement reconcile_accounts(source, target). Source rows contain id and amount as a decimal string in currency units. Target rows contain id and cents as an integer. Normalize IDs with strip().lower(), then return sorted missing, unexpected, and changed IDs.

Requirements

  • Both inputs are lists of dictionaries. IDs are nonempty strings after normalization and unique within each input.
  • Source amount must be a finite decimal string with no fractional cents. Target cents must be an int, not bool. Negative balances are valid.
  • Reject invalid input or duplicate normalized IDs with ValueError. Do not modify either input.
  • Return {"missing": [...], "unexpected": [...], "changed": [...]}. Compare only IDs present on both sides for changed.
ReconciliationDecimal arithmeticNormalization

Loading exercise…