Lesson 25 of 27Practice and polish
Multi-Part Practical Problems
Solve specs revealed in levels, like an in-memory database that gains scans, TTLs and backups, by reading fast and designing for the next change.
Some coding rounds do not hand you a puzzle. They hand you a spec: "Build an in-memory database that supports set, get and delete." You build it, the tests pass, and a new section appears: "Now add prefix scans." Then: "Now every operation takes a timestamp, and values can expire." Then: "Now support backup and restore." Each level builds on the code you already wrote, so a shortcut in level 1 becomes a rewrite in level 3. This format rewards a different skill from the classic algorithm round: reading a long spec quickly, choosing a data model that bends instead of breaks, and keeping your code clean while a timer runs. It is also the closest thing in interviewing to a normal week at work.
The format
The best-known example is CodeSignal's Industry Coding Framework (ICF), used by a number of companies as an online assessment for mid-level and senior roles. As CodeSignal describes it at the time of writing (late 2026), it is a single task split into four levels over about 90 minutes, with automated tests for each level. Typical tasks are an in-memory database, a banking system, a file storage service or a task queue. Formats, timing, scoring and the rules for when the next level unlocks change, and companies can configure their own versions, so check CodeSignal's current candidate docs and whatever the recruiter sends you before you sit it.
Live practical rounds follow the same shape. Candidates commonly report this style at fintech companies such as Stripe, Ramp and Coinbase: a realistic multi-part problem, often with an interviewer adding the next part when you finish the current one. Treat these reports as a description of the genre, not of any company's current process.
Whatever the platform, the levels usually escalate like this:
| Level | What it adds | What it tests |
|---|---|---|
| 1 | Basic CRUD operations on a simple model | Can you read a spec and get the contract exactly right? |
| 2 | Queries over the data: scans, filters, sorting, top-n | Can you extend without breaking level 1? |
| 3 | Time: timestamps, TTLs, scheduled actions, history | Does your data model admit a new dimension? |
| 4 | State over time: backup and restore, undo, merges, transfers | Can you copy, roll back and reason about edge cases under pressure? |
Few candidates finish all four levels. Scoring typically rewards each passing test, so a clean, fully passing level 3 beats a half-working level 4.
Reading a long spec fast
A level spec is often a page of prose with method signatures buried inside. Do not read it like a story. Extract a checklist before you type, in this order:
- Operations. Every method name and its parameters, exactly as spelled. Tests call them by name.
- Return contract. What each one returns on success, and what it returns on "not found".
None,"",Falseand an exception are four different answers, and the tests will check which one you chose. - Output format. If a method returns a string such as
"name(Ada), city(London)", copy the format character by character. Spacing and ordering mistakes fail tests that your logic would pass. - Ordering rules. "Sorted by field name", "by balance descending, ties by account id": these are where hidden tests cluster.
- Error cases. Missing keys, duplicate creates, transfers to self, insufficient funds.
- Hints about the future. A field you do not need yet, such as a timestamp argument that is "ignored in this level", is the spec telling you what comes next.
You have just opened level 1 of a practical task. Put these first steps in order.
- Tap the steps below in the right order.
Design for the next level, not the last one
You cannot see level 3 while you write level 1. You can still make choices that keep it cheap to add. Three habits do most of the work.
Put every rule in one place. If "is this field visible?" is decided in one helper, adding expiry in level 3 changes one function. If every method reads the dict directly, level 3 changes every method, and you will miss one.
Make simple versions call general ones. Once timestamps appear, rewrite get(key, field) as get_at(key, field, None). Two code paths that must agree will drift; one path cannot.
Store a small record, not a bare value, once there is a second attribute. A bare string becomes Entry(value, expires_at) the moment expiry appears. A NamedTuple or frozen dataclass is immutable, which also makes level 4 copies safe.
What you should not do is build for imagined levels: generic plugin systems, abstract base classes, an event bus. That costs minutes you need, and the real level 3 rarely matches what you guessed. The aim is code that is easy to change, not code that already handles everything.
Level 1 needs only a dict of dicts. A record per key, a value per field. setdefault creates records lazily.
Worked example, levels 1 and 2
Here is level 1 (set, get, delete) and level 2 (scan, scan_by_prefix) written the way you would under time. The tests at the bottom are the kind you should write yourself as you go: one or two asserts per operation, including the not-found case.
Press Run (⌘ Enter) to see what happens.Small choices worth noticing: scan is scan_by_prefix with an empty prefix, so the sort and format live in one place. delete removes empty records, which matters later when a level asks "how many keys are there?" And every not-found path returns the same kind of thing for the same method: None for get, False for delete, [] for scans.
Worked example, levels 3 and 4
Level 3 says every operation gains a _at version with a timestamp, and set_at can take a TTL: a value set at time 10 with TTL 5 is visible at times 10 to 14 and gone at 15. Level 4 adds backup(ts), which saves the live state and returns the number of non-empty records, and restore(ts, ts_to_restore), which restores the latest backup taken at or before ts_to_restore. The twist that trips people: a restored value keeps the remaining lifetime it had at backup time, counted from the restore time.
Press Run (⌘ Enter) to see what happens.Look at how little of level 1 and 2 changed. The four original methods became one-line wrappers, and all of the time logic sits in _live, set_at and the level 4 methods. That is the payoff from routing reads through one helper early.
Two details in level 4 are classic hidden-test targets. First, expires_at - ts converts an absolute expiry into a remaining lifetime, and restore converts it back with the new time. Storing absolute expiry in the backup would make every restored TTL wrong. Second, the backup is built from new dicts and immutable entries, so later writes cannot leak into it.
What does this print?
data = {"a": {"x": "1"}}
backup = dict(data)
data["a"]["x"] = "2"
print(backup["a"]["x"])Match each new level requirement to the change it forces in your data model.
Test-driven speed
Automated tests are your score, so run them constantly.
- Run after every operation, not after the whole level. A failing test with two new methods is a two-place search. With eight, it is a debugging session.
- Read the failing assertion before the code. "Expected
['a(1)', 'b(2)'], got['b(2)', 'a(1)']" says sorting. "ExpectedNone, got''" says contract. Most level failures are format or contract mismatches, not logic. - Write your own asserts for the edges the spec mentions and the visible tests do not cover, because hidden tests usually cover exactly those: not found, duplicates, empty results, ties in sort order, boundary times such as
ts == expires_at. - Take partial credit deliberately. If a level is mostly passing and one awkward test remains with 20 minutes left, read the next level. Its first tests are often easier than the last test of the current one. Where the platform lets you move on, the score usually counts tests passed, not levels completed.
get_at uses ts <= expires_at. A hidden test fails. What is the most likely cause?Clean code under a timer
Practical rounds are often reviewed by a human afterwards, and live versions are watched as you type. Messy code that passes can still cost you.
- Name things from the spec. If the spec says "record" and "field", your variables say
recordandfield, notdandk2. - One contract per method. Pick the not-found value the spec gives and use it on every path. A
getthat returnsNoneon a missing key but raisesKeyErroron a missing field is a bug waiting for a hidden test. - No dead branches. Delete the commented-out level 2 attempt. Unused parameters with a note ("ts reserved for level 3") are fine; abandoned code is not.
- Small helpers over long methods.
_live,_format,_require_account. Each later level then reads like a short list of steps. - Refactor between levels, not during. When a level passes, spend two minutes on the obvious duplication before you read the next spec. Refactoring while tests fail mixes two kinds of change, and you lose track of which one broke things.
- Industry Coding Framework
- CodeSignal's multi-level practical assessment format: one task, extended in levels, scored by automated tests. Check current docs for timing and rules.
- level
- One stage of a practical task that adds requirements on top of the code from earlier stages.
- return contract
- The exact value a method returns for each outcome, including not found and invalid input.
- TTL
- Time to live: how long a value stays visible after it is set before it counts as expired.
- half-open interval
- A range that includes its start and excludes its end, such as [10, 15).
- snapshot
- A copy of state at one moment that later writes cannot change.
- shallow copy
- A copy of the outer container only, whose nested objects are still shared with the original.