Skip to content
mager-bench1.3
← historical challenges

refactor

Refactor messy code and explain each change

the prompt

$ cat refactor.prompt
Refactor the following Python function and explain each change you made:

```python
def p(d):
    r = []
    for i in range(len(d)):
        x = d[i]
        if x % 2 == 0:
            r.append(x * x)
        else:
            r.append(x * x * x)
    return r
```

Requirements: rename everything meaningfully, use a list comprehension or equivalent, add a docstring, add type hints. Then write a short explanation of each change.

rubric

correctness

Does the refactored function produce the same output as the original?

quality

Are the names meaningful? Is the list comprehension idiomatic? Is it more readable?

documentation

Is the docstring clear? Is the explanation of changes clear and specific (not generic)?

results

GPT-6 Astra

10.0
correctness 10.0quality 10.0documentation 10.09476ms

# The refactor exactly preserves behavior and order while using clear names, an idiomatic comprehension, precise type hints, a concise docstring, and a specific explanation of every meaningful change.

inspect full trace →

GPT-5.6 Sol

9.7
correctness 10.0quality 10.0documentation 9.06098ms

# The refactor is behaviorally equivalent, idiomatic, clearly named, and fully typed, with a concise docstring and specific explanation that could only be improved by documenting parameters and the return value.

inspect full trace →