Evaluating LLM Coding Ability with Challenging Algorithmic Problems
Challenging programming problems can reveal differences in LLM coding ability that simple code-generation tasks miss. Using time-dependent shortest paths and event-log replay as examples, this article examines algorithm selection, multi-objective ordering, integer precision, idempotency, and state-machine correctness. It also outlines a reproducible evaluation process built around layered tests, automated judging, and cross-model review.
1. Why LLM Evaluation Needs Challenging Programming Problems
As large language models improve at code generation, simple benchmarks—such as completing a line of code or implementing a sorting function—become less useful for distinguishing their capabilities. Many models perform similarly on routine tasks. The differences become clearer when problems require problem modeling, careful edge-case handling, complex data structures, and algorithm design.
From an engineering perspective, a useful coding evaluation problem should have four characteristics:
- Machine-verifiable correctness: Results should be deterministically verifiable through automated tests rather than subjective scoring.
- Non-obvious challenges: A straightforward-looking specification should contain details that expose weaknesses in a model’s reasoning or implementation.
- Production-scale constraints: Inputs such as 10^5 nodes or timestamps as large as 10^18 test whether a model understands computational complexity and numerical precision.
- Multiple dimensions of correctness: A task might require the earliest arrival, then the lowest cost, then the lexicographically smallest path. This tests whether the model respects the priority order of optimization objectives.
One evaluation approach is to have one model create a problem and another solve it, followed by cross-review or automated judging. This problem-setting, solving, and review loop can support more objective comparisons of model capabilities.
2. Case Study: Shortest Paths in a Time-Dependent Graph
A representative challenge is a shortest-path problem with periodic departure constraints:
Given a directed graph, each edge has a departure phase, a period, a traversal duration, and a cost. If a traveler reaches a node at time T, they may traverse an edge only at a departure time that satisfies its modular constraint. Otherwise, they must wait until the next valid departure. Return a tuple containing the earliest arrival time, the minimum total cost among routes achieving that arrival time, and the lexicographically smallest corresponding path. Return None if the destination is unreachable.
The core interface can be expressed as:
def timed_shortest_path(n, edges, s, t, start_time):# edges: (u, v, phase, period, duration, cost)# Return (earliest_arrival, min_cost, path) or None...
This problem tests several layers of algorithmic and engineering competence.
Algorithm Selection and Departure-Time Calculation
The underlying algorithmic approach is a Dijkstra variant for a time-dependent graph. Arrival time determines when an outgoing edge becomes available, so relaxation must account for waiting.
The next valid departure can be calculated using an expression such as:
depart = T + ((phase - T) mod period + period) mod period
The modular arithmetic requires care. An incorrect treatment of remainders can produce a negative waiting offset.
Ordered Optimization Objectives
The objectives have a strict priority:
- Earliest arrival time.
- Lowest total cost among routes with that arrival time.
- Lexicographically smallest path among routes tied on both.
A single scalar weight does not directly express this ordering. The implementation needs comparison logic that respects the tuple (time, cost, path).
Path comparisons can also introduce additional computational overhead, making their implementation part of the evaluation.
Integer Precision
The starting time can be as large as 10^18, while individual durations and costs can reach 10^9. Accumulated values can therefore exceed the range in which floating-point numbers represent integers exactly.
The intended implementation uses arbitrary-precision integer arithmetic throughout, rather than floating-point arithmetic. This is an important, easily overlooked test of whether a model reads and applies numerical constraints.
Edge Cases and Degenerate Inputs
The specification contains several details that deserve explicit tests:
- Period of 1: Every integer departure time is valid, so no waiting is necessary.
- Identical source and destination: The function should immediately return
(start_time, 0, [s]). - Paths tied on time and cost: Lexicographic tie-breaking must be consistent.
- Parallel edges: Every edge between the same pair of nodes must be considered, rather than retaining only the first.
- Zero-cost edges: They do not increase the secondary objective, but they can still affect path selection.
Typical failures on problems of this kind involve a broadly correct algorithmic structure with errors in waiting-time calculations, lexicographic tie-breaking, or integer-range handling. Such failures suggest that a model can recognize an algorithmic pattern without fully accounting for every constraint.
3. Case Study: Event-Log Replay and Idempotency
Another useful problem category is consistent replay of out-of-order event logs:
Each event contains a timestamp, an actor, an idempotency key, an operation type, and a payload. The system maintains objects with owners and values. Events must be replayed in ascending order of
(timestamp, actor, idempotency key). For a given actor, only the first occurrence of an idempotency key takes effect. Creation, ownership transfer, and deletion follow ownership-based permission rules. Snapshot operations record the state of specified objects at the required point in the replay; missing objects are recorded as None.
A representative interface is:
def reconcile(events):# events: (ts, actor, op_id, kind, payload)# kind is one of {"add", "move", "delete", "snapshot"}...
Although this task does not appear to require a sophisticated algorithm, it tests state-machine modeling and complete implementation of business rules.
Composite Sorting
The replay order combines integer and string fields. The implementation must construct the composite key correctly and apply each comparison level in the specified order.
Idempotent Deduplication
A set of (actor, op_id) pairs is needed to track previously encountered keys. Repeated events for the same actor and key must be silently ignored rather than treated as errors.
Permission Enforcement
Only an object’s current owner may transfer or delete it. The implementation must also check that the object exists before applying ownership checks or changing its state.
Models can miss this prerequisite when translating permission rules into conditional branches.
Snapshot Semantics
A snapshot captures the state visible at its position in the replay sequence. It must therefore execute at the correct point in the processing flow.
Deleted or nonexistent objects should be recorded as None, not trigger an exception.
This category maps closely to backend engineering tasks such as event sourcing and audit-log replay. It tests whether a model can translate a natural-language specification into unambiguous code without losing business rules.
4. A General Method for Evaluating LLM Coding Ability
The two examples suggest a practical evaluation framework.
1. Use Layered Difficulty
An evaluation suite should cover four levels:
- Correctness of the overall algorithm or processing structure.
- Completeness of implementation details.
- Extreme and degenerate inputs.
- Performance under the stated constraints.
Layered testing helps distinguish capabilities more precisely and avoids a ceiling effect caused by a uniformly easy test set.
2. Test Each Non-Obvious Requirement Explicitly
Potential failure points—such as overflow, degenerate inputs, parallel edges, and idempotency conflicts—should each have dedicated test cases.
The results should identify specific causes of failure, not merely report an aggregate score. This makes the evaluation more useful for diagnosing model weaknesses.
3. Combine Cross-Model Review with Automated Judging
Different models can alternate between setting and solving problems, while automated judging scripts determine whether solutions pass.
A model’s admission that its answer is wrong is not a substitute for testing. Its diagnosis may itself be incorrect, so both solutions and error explanations require verification.
4. Make Results Reproducible
Fix random seeds, input datasets, and the execution environment. Reproducibility makes results comparable across runs and allows teams to track changes between model versions.
5. Align Problems with Engineering Work
Whenever possible, connect evaluation tasks to realistic engineering concerns:
- Graph problems can reflect routing and scheduling.
- Log-replay problems can reflect event sourcing and data consistency.
This alignment makes benchmark results more relevant to practical model selection.
5. Conclusion
Challenging algorithmic problems help distinguish code that merely looks correct from code that remains correct under demanding constraints.
Rather than relying on a single trial or an informal impression, development teams can establish a continuous evaluation process with a layered problem set, automated judging, cross-review, and a reproducible environment.
This turns model assessment into a measurable engineering practice. It supports technology selection and provides an evolving capability baseline as model versions change.
