Apply repeated events exactly once locally
Reduce events with source, id, account, and signed integer delta. Identity is the pair (source,id). Apply the first occurrence, ignore identical repeats, and reject a repeated identity with a different account or delta. Return account balances; negative balances are allowed because these are general counters, not financial accounts. Validate nonempty string identities and integer deltas excluding booleans. This is an in-memory projection exercise, not a claim of end-to-end exactly-once delivery.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
Inputs1/1 adds 3 to x, then identical s1/1
Output{'x':3}
Inputs1/1 adds 3 and s2/1 adds 4
Output{'x':7}
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor