When AI Meets Combinatorial Explosion: A Post-Mortem on a Failed Monthly Puzzle
This article walks through a failed attempt to solve a monthly public optimization puzzle from a top quantitative firm using a general-purpose LLM and generic search. It breaks down why the puzzle is structurally hostile to AI (complex geometric validation, globally coupled constraints, rapidly expanding state space), where the generic agent pipeline broke down, and why constraint solvers or integer programming are the right tool. Readers will also find a practical solver-oriented design, sample pseudocode, and a developer checklist for choosing between modeling and prompt stacking.
1. Why a Failure Is Worth Reviewing
Most technical articles only show the success path, but failures often expose the limits of a methodology more clearly. The target here was a public puzzle released monthly by a top quantitative firm. The rules look simple, but the problem is really a layered combination of combinatorial optimization and geometric reasoning. Participants must place 90° arcs of radius 1 into the white cells of a 9×9 grid; green cells are off-limits. Once the arcs connect end to end, they cut the grid into several enclosed regions. Each region must have an integer area and carries a score defined as “area × number of smooth boundary segments.” The region containing a numbered cell must have a score equal to that number. The final score is determined jointly by the sum of squares of the row sums and the column sums.
I worked with an AI coding tool for about four hours straight, and in the end both of us failed. The process, however, fully exposed the structural weaknesses of a “general-purpose large model + generic search” approach on problems with enormous state spaces, which is more valuable than a forced answer.
2. Why the Problem Is Naturally “Anti-AI”
This is not an ordinary logic puzzle. It carries three layers of difficulty at once.
First, geometric validity is complex to check. How arcs connect determines whether a region is closed, and whether a boundary is smooth requires checking tangent continuity segment by segment. Any local choice can change the global topology.
Second, the constraints are globally coupled. Region area, smooth-segment count, and the numbered-cell constraints constrain one another and cannot be split into independent subproblems that are solved separately and then reassembled.
Third, the state space expands sharply as you progress. Just enumerating locally valid geometries for the central region labeled 35 produced 4,553 candidates. By the time the search reached the region labeled 45, the visited-state set filled 12GB of memory, and the process was terminated twice in a row by the system’s memory reclamation mechanism.
In other words, the puzzle design itself penalizes the generic “enumerate first, then prune” strategy and rewards the specialized “model first, then solve” strategy.
3. The Generic Agent’s Execution Path and Failure Points
My approach had three steps: first, write a geometry engine that could compute area and smooth-segment count for any arc configuration; second, enumerate all geometrically valid local solutions for each numbered cell; third, use constraint propagation to converge step by step.
The failure points were clear:
- The number of local candidates reached the thousands in the middle regions, making the Cartesian product uncontrollable;
- Constraint propagation lacked strong pruning, so equivalent states were repeatedly enqueued;
- States were kept in memory as full snapshots, with no incremental representation or deduplication compression.
The tool’s judgment at the time was to stop proactively: rather than submit a number that was most likely wrong, it was better to state clearly that the problem could not be solved to completion. That judgment was reasonable from an engineering standpoint, because joint consistency checking across 18 regions had already exceeded what a general-purpose model plus generic search could handle.
4. A Pragmatic Way to Wrap Up
Since the first participation was mainly about making a connection, I had the tool do a greedy fill based on three different central-region candidate scenarios, producing three candidate solutions: a compact L-shape corresponding to 2,497,012; a top-and-bottom double arc corresponding to 2,297,084; and a version extending right to the boundary corresponding to 2,579,416. The one submitted in the end was the third, with the fewest unresolved regions. It is almost certainly wrong, but it closed the loop on the process.
A comparison experiment also made the point: switching to a one-shot, question-and-answer style general assistant meant the constraints were basically not fully incorporated, and the output clearly deviated from the problem. This kind of task needs continuous state maintenance and multi-round self-checking, not single-turn generation.
5. The Right Approach: Hand the Problem to a Constraint Solver
The conclusion after the review: this kind of problem should be handed to a specialized constraint-solving approach, such as a finite-domain constraint framework or an integer programming modeling tool, rather than making a general-purpose model do the search by force. The recommended pipeline is:
- Variable design: model each cell’s arc direction and region membership as finite-domain variables;
- Constraint encoding: write integer area, smooth-segment counting, and the numbered-cell equalities all as hard constraints;
- Search strategy: use region connectivity for forward pruning, combined with a minimum-remaining-values heuristic for variable selection;
- Objective optimization: hand the sum of squares of the row sums and column sums to the solver as the objective function for iteration.
Illustrative pseudocode:
# Variables: cell_dir[r][c] ∈ {empty, four 90° arcs}# Region ID region_id[r][c] is derived from connectivitymodel = ConstraintModel()for cell in grid:if cell.is_green:model.add(cell_dir[cell] == EMPTY)for region in candidate_regions:model.add(is_integer(region.area))model.add(region.area * region.smooth_segments == region.score)for numbered in numbered_cells:model.add(region_of(numbered).score == numbered.value)model.minimize(row_sum_sq + col_sum_sq)
On the engineering side, geometric validity can be precomputed into a lookup table to avoid repeated online checks; states can be incrementally hashed to cap memory usage; and when necessary, candidate scenarios can be split horizontally across a container platform and solved in parallel, with logging services and monitoring alerts tracking search depth and pruning rate.
6. A Selection Checklist for Developers
- For problems with strongly coupled constraints that need global consistency, prioritize modeling and solving over stacking prompts;
- For tasks with large state spaces, estimate the memory upper bound first, then decide whether a specialized solver is needed;
- Let the general-purpose model handle modeling, code generation, and result interpretation, and leave exhaustive search and proofs to the solving engine;
- Use general-purpose capabilities such as the container platform, logging service, and monitoring alerts on Baidu AI Cloud to carry parallel search and observability, so that single-machine memory does not become the bottleneck.
AI has limits, but those limits can be worked around with engineering: identifying the problem structure and choosing the right toolchain is more effective than grinding away with more time.
