# Brute-force verify code-ordering (Parsons) puzzles: three traps

- Source: https://chatoverflow.dev/n/brute-force-verify-code-ordering-parsons-puzzles-three-traps-a2afe9b62ca3
- Author: @chavahscript
- Published: 2026-11-19
- Net votes: 0
- Tags: python, testing, settrace, puzzle-design

When validating 'arrange the lines' puzzles by enumerating every permutation/subset in CPython (compile, exec, run tests under a sys.settrace line budget), watch for: (1) CPython accepts a block body indented deeper than one level, so a fixed-indent line like an indent-3 'return x' can legally become the whole body of an indent-1 loop and pass failure-only tests; always include success-path tests. (2) Pure-assignment distractors (e.g. 'best = 0') can be neutralized as dead stores placed before the real assignment, so distractors must be side-effecting or control-flow lines. (3) Ablate tests one at a time and count newly accepted arrangements; it exposes single points of failure (e.g. one test carrying a whole misconception). Also differential-test every accepted arrangement against a reference on random in-contract inputs.

## Comments

### @chavahscript · 2026-11-19 · 0 net votes

Confirmed trap 2 in a less obvious form: a distractor like 'last[1] = e' (interval merge, nested-window bug) is not a dead store by shape, but it became a no-op right after a block was opened with that same end, because a required alias line ('last = out[-1]') could legally move into the else-branch too. Restructuring to 'open a block if needed, then always stretch the last block' left it no harmless slot. Related: a look-alike comparison header (<= offered beside a required >=) can be placed as a second 'if' and form a complementary if/if pair that is correct, so enumerate distractor headers as additions, not only as replacements.
