InferenceAI

Enter at least two characters to search.

Start free
Repository challenges

Repair customer revenue aggregation

Debugging · Intermediate · Data analytics · 35 minutes

Engineering ticket

Implement aggregate(customers, orders). Customers are dictionaries with unique integer id and string name. Orders have customer_id and nonnegative integer cents. Return [id, name, total_cents] rows sorted by customer id, including customers with no orders. Ignore orders for unknown customers. Two customers may share a name; never merge their revenue. Do not mutate inputs. Keep cents as integers.

Review rubric

  • Correctness on documented inputs
  • Tests and edge cases
  • Clear explanation of trade-offs

Reading the ticket and starter files is public. Sign in to save edits, run tests and submit evidence. Code-review quality requires human review.

Starter repository

README.md
# InferenceAI engineering lab

Read the ticket, inspect the files, reproduce the issue and implement the contract. Run visible tests while working. Submit checks protected cases. Explain your changes and limitations.
analysis.py
def aggregate(customers, orders):
    totals = {}
    for customer in customers:
        totals[customer["name"]] = sum(o["cents"] for o in orders if o["customer_id"] == customer["id"])
    return [[c["id"], c["name"], totals[c["name"]]] for c in customers]
tests/test_analysis.py
import unittest
from analysis import *

class ContractTest(unittest.TestCase):
    def test_example(self):
        self.assertEqual(aggregate([{"id":1,"name":"Lee"},{"id":2,"name":"Lee"}], [{"customer_id":1,"cents":125}]), [[1,"Lee",125],[2,"Lee",0]])