Skip to content
Next HR
All resourcesGuides

Designing coding assessments: realistic problems, hidden tests and fair scoring

A coding task should measure what developers do, not whether they remember a puzzle. How to pick a problem, write visible and hidden tests, set the time and languages, score partial credit and follow up on the solution, with a worked example.

Emma HartleyHead of assessment design

January 28, 2025

Key takeaways

  • Pick a problem that looks like the job: parsing, transforming and validating data beats contrived puzzles.
  • Use visible tests so candidates can check their understanding, and hidden tests for edge cases and fairness.
  • Score by passing tests, and add human review for readability and design, scored against a rubric.
  • Plan to talk about the solution afterwards: it is the best check that the work is the candidate’s own.
In this article
  1. Choose the problem
  2. A worked example
  3. Write visible and hidden tests
  4. Set the time and the language
  5. Score fairly
  6. Follow up in conversation
  7. More problem ideas
  8. Follow-up questions for the conversation

Many coding assessments are unpopular with candidates, and with good reason: they ask for algorithm trivia under pressure that nobody faces at work. A better design asks for a small, realistic piece of programming and judges it by what the code does.

Choose the problem

  • Realistic. Parsing logs, reconciling two lists, validating input, summarising records, designing a small class. Not “reverse a linked list”.
  • Bounded. Doable in 20 to 45 minutes by someone competent in the language, including reading the problem and testing.
  • Clear. An unambiguous statement, with inputs, outputs and edge cases described. Ambiguity tests mind-reading.
  • Open to different approaches. Several solutions of different quality should be possible, so you can see judgement, not recall.

A worked example

Sample coding problem: error counts per service text
# Problem
Each log line has the form:
  <timestamp> <service> <level> <message>
Write error_counts(lines) that returns a list of (service, count) pairs for
lines whose level is exactly ERROR, ordered by count (highest first) and
then by service name (A to Z). Ignore lines that do not have at least
three space-separated parts.

Example
  lines = [
    "2026-03-01T10:00:01Z payments ERROR timeout",
    "2026-03-01T10:00:02Z search INFO ok",
    "2026-03-01T10:00:03Z payments ERROR declined",
    "2026-03-01T10:00:04Z auth ERROR bad token",
    "bad line",
  ]
  error_counts(lines) -> [("payments", 2), ("auth", 1)]

Write visible and hidden tests

Visible tests show the candidate the shape of the answer and let them check their understanding. Hidden tests check what a careful developer would think of: empty input, a tie in counts, a malformed line, a level in lower case, extra spaces.

Test plan for the example
TestVisible?What it checks
The example aboveYesBasic behaviour and ordering by count
Empty listYesReturns an empty list, no crash
Two services with equal countsNoTie broken by service name
Level “error” in lower caseNoLevel must be exactly ERROR
A line with only two partsNoMalformed lines ignored
10,000 linesNoReasonable efficiency, not a trick

A reference solution proves the problem is solvable and the tests are right. Always run it against your own tests before a candidate sees them.

A reference solution python
def error_counts(lines):
    counts = {}
    for line in lines:
        parts = line.split(maxsplit=3)
        if len(parts) < 3:
            continue
        service, level = parts[1], parts[2]
        if level == "ERROR":
            counts[service] = counts.get(service, 0) + 1
    return sorted(counts.items(), key=lambda kv: (-kv[1], kv[0]))

Set the time and the language

Pilot the task with people who write code for a living, and set the limit from their times plus a margin for reading and checking. Let candidates choose from the languages you offer, because the skill is programming, not one syntax. If a language needs something installed on the candidate’s computer, say so before the test.

Score fairly

  1. Automated scoringPassing tests is objective and consistent. Weight hidden tests so that careful handling of edge cases counts, and award partial credit by tests passed.
  2. Human reviewFor finalists, a reviewer reads the code against a short rubric: correctness, clarity, structure, handling of errors. Score each separately and anonymously.
  3. Interpret results with careA failed hidden test is evidence to explore in the interview, not proof of poor ability. Time pressure and unfamiliar tools cause misses.

Follow up in conversation

A short conversation after the test is the best way to see that the solution is the candidate’s own. Ask why they chose the approach, how it would change with ten million lines, what they would test next. A person who wrote the code can answer easily. This also reduces the temptation to rely on AI or a friend, without surveillance.

In Next HR

Coding questions run in an editor in the candidate app, with visible and hidden test cases scored automatically. See the documentation on question types for how to write them.

More problem ideas

Realistic problems that suit a 30-minute task
IdeaWhat it showsEdge cases to test
Merge two sorted lists of records by dateHandling of ordering and duplicatesEmpty list, equal dates, one list much longer
Validate a form payload and return a list of errorsInput validation, clear error messagesMissing field, wrong type, extra whitespace
Deduplicate customer records by email, keeping the most recentData cleaning, choosing a keyDifferent letter case, blank emails
Compute a running balance from transactionsState, rounding, orderingNegative amounts, same-day transactions
Rate-limit a stream of events (no more than N per minute per user)Time windows, data structuresBursts at window boundaries

Follow-up questions for the conversation

  • “Walk me through your approach. What did you try first?”
  • “What would you test next if you had ten more minutes?”
  • “How would this change with a hundred times as much data?”
  • “If a colleague reviewed this, what would they probably comment on?”
  • “Is there a simpler way you rejected? Why?”

These questions are as useful when candidates have used an assistant as when they have not. A person who understands the code can answer them easily, and one who does not will struggle however polished the solution is.

About the author

Emma Hartley, Head of assessment design

Emma designs assessments and interview guides, from question writing and scoring rubrics to take-home tasks and accessibility. She writes practical, step-by-step guidance for teams building their first fair process.

Frequently asked questions

Ready to find the right candidate?

Book a short walkthrough and see Next HR rank candidates against your role. We will tailor it to your hiring process.