Fix the survivor report for mutation testing
Your task
An agent implemented a feature and wrote its tests too, and everything is green. Tests written by the same model as the code tend to assert what the code already does, bugs included. So your team runs mutation testing: it plants small bugs, called mutants, and checks whether any test fails on each one. A mutant no test catches is a bug the green suite would have shipped.
An assistant wrote find_surviving_mutants(mutant_ids, killing_test_counts). It is in the editor. It has a bug. Find it and fix it.
Input and output:
mutant_ids: the mutant tested in each run, in order. The same id can appear in several runs.killing_test_counts: for each run, how many tests failed on that mutant. The runner reports -1 when a run crashed or timed out. This list can be shorter thanmutant_ids, and a missing count counts as 0.- Return the ids of the surviving mutants, each once, sorted by plain character order.
Rules the tests check:
- A run catches its mutant only when its count is 1 or more. A count of 0, a negative count and a missing count are not catches.
- A mutant is caught when any of its runs catches it.
- Every id that is never caught survives.
Examples
find_surviving_mutants(mutant_ids: list[str], killing_test_counts: list[int]) -> list[str]Example 1
Input
find_surviving_mutants(["m1", "m2", "m3"], [2, 0, 1])Output
["m2"]Example 2
Input
find_surviving_mutants(["off_by_one", "null_input"], [0, 0])Output
["null_input", "off_by_one"]Example 3
Input
find_surviving_mutants([], [])Output
[]