Setup

No AI for this kata.

A nightly import cleans up a list of customer records. A profiler shows almost all the time is spent in this function:

def dedupe(records):
    seen = []
    result = []
    for r in records:
        key = (r["email"].lower(), r["country"])
        if key not in seen:
            seen.append(key)
            result.append(r)
    return result

With 10,000 records (about 30% duplicates), it takes 0.4 seconds. Next month’s import will have 100,000 records, with the same duplicate rate.

After you commit, do the kata itself:

  1. Explain in one sentence why the time grows the way it does.
  2. Rewrite dedupe so it scales linearly, without changing which record is kept for each duplicate.
  3. Run both versions under a profiler at 10,000 and 100,000 records and compare the profiles.

Commit before you see the outcome

Your call

This takes 0.4 seconds for 10,000 rows. Predict how many seconds it takes for 100,000 rows.

Move the slider (or use the arrow keys) to set it. 0% is a pure guess; 100% means you'd bet on it.

After you reveal, your answer and confidence are locked. That's the point.