BlogAI & ML

How to Write Test Cases That Catch Wrong Solutions

Strong test cases for coding problems are built to reject wrong solutions, not just pass the right one. How our problem setters write and use a kill list.

Nomos Insights
Updated 5 min read

When you write tests for a programming problem, it's natural to ask whether the right solution passes. For AI evaluation, the more important question is whether every wrong solution fails.

To write strong test cases for a coding problem, start from the wrong solutions, not the right one. Our problem setters write real programs for the mistakes a model is likely to make, such as a wrong greedy choice, an off by one bound or an overflow, then add tests until every one of them fails.

A model doesn't need to be correct to pass weak tests. It just needs a shortcut the tests don't catch. Public benchmarks, fixed task sets used to compare models, have the same problem. When researchers extended the tests of the HumanEval coding benchmark by 80 times, pass rates fell by up to 28.9 percent, because the original tests had been letting wrong code through (Rigorous Evaluation of Large Language Models for Code Generation).

So for every competitive programming problem we write, our setters also write a list of wrong solutions. We call it the kill list, and the test suite, the full set of tests for the problem, has to kill every one of them. In one validation report, the final tests rejected all 13 wrong solutions on the list.

Which wrong solutions do we write first?

The ones a model is most likely to try:

  1. Constant output. Print the same answer every time and hope.
  2. Guessing by input size. Return something based only on how big the input is.
  3. Wrong greedy. A greedy approach, one that takes the best looking choice at each step, which works on small cases but fails on the right counterexample.
  4. Off by one. The classic. Loops and bounds one step off.
  5. Overflow. Correct logic with numbers that silently grow past what their type can hold on large inputs.
  6. Too slow. A correct but slow approach that should time out on worst case inputs.

Each entry is a real program, not a description. The setter writes it, runs it against the tests and checks that it fails. If a wrong solution survives, the tests are not done.

Why isn't passing every test enough?

Because a shortcut can pass every case you wrote without being the real algorithm. We learned that on one problem where a shortcut passed all 22 of our tests, each in under a hundredth of a second. It just happened to work on every case we'd written.

We added dense test cases built to force the real algorithm, and the shortcut died. That case set a rule we still follow: write the shortcut first, on purpose, and build tests to kill it.

It could count but couldn't pick

One of our favorite lessons came from a failing model run. On one problem the model produced 91 wrong answers. Our reviewers went through them and found the same thing in every one: the count was right but the chosen items were wrong, which was exactly the mistake we'd planted on our kill list.

An earlier version of that problem, before we rebuilt the tests to catch the mistake, had been solved seven times out of eight. After the rebuild, the model's shortcut stopped working. That's the kill list doing its job.

Edges, worst cases and the grader itself

We also check the edges. Large inputs where no answer exists. Worst case inputs right at the time and memory limits. Tests at the exact maximum constraint. A solution that only works on friendly inputs shouldn't pass.

Sometimes we test the grading setup too, as part of making sure a grader is fair. In one red team probe we tried a trick where a custom number type claims to equal everything. The output format turned it back into a normal number, so the trick failed. Good. We'd rather find out our grading can't be fooled before a model tries.

When a model learns from problems with weak tests, it learns shortcuts. With strong tests it has to learn the real idea. The kill list is a little extra work per problem, and it's the difference between data that teaches reasoning and data that teaches guessing.

Quick answers

What is a kill list in test design? A set of deliberately wrong solutions our problem setters write for each problem. The tests must reject every one before we call them strong.

What wrong solutions should every test suite catch? Our setters always cover constant output, guessing by input size, wrong greedy, off by one errors, overflow and solutions that are too slow, and run each one against the tests.

Why do AI models pass weak tests? Because they often find shortcuts that happen to work on the given cases. That is why our setters write the shortcut first and build tests to kill it.

How many test cases does a coding problem need? There is no fixed number. Our setters stop when every wrong solution fails and the worst case inputs reach the time and memory limits.


Need Coding Problems With Tests That Hold?

Our problem setters build test suites for AI labs and model teams that reject shortcuts. You get reasoning data that meets your bar, on schedule.

Get in Touch
Filed underTest DesignCompetitive ProgrammingAI ReasoningTraining Data