Conversation
beackers
commented
Feb 4, 2026
- saving before deleting, just so I know how bad it was
- resetting
- define states module
- added canonical states, min heap, priority queue
- optimizations
- change tests
- Improve search performance and operations
added branching within bounds, fixed strange sorting due to storing results by state key instead of number, fixed targeting error (half-width instead of midpoint)
…eration-solutions Improve heap performance, add integer-only ops and exponent support, and safer reachability pruning
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77125a3938
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
states.lua
Outdated
| local sumAbs = 0 | ||
| for _, v in ipairs(state.raw) do | ||
| sumAbs = sumAbs + math.abs(v) | ||
| end | ||
| local lower = -sumAbs | ||
| local upper = sumAbs | ||
| return not (max < lower or min > upper) |
There was a problem hiding this comment.
Fix pruning that rejects reachable targets
The canReach heuristic assumes all intermediate results stay within [-sumAbs, sumAbs], but this is false once multiplication or exponentiation is allowed. For example, with numbers [6, 6] and a target range of 36..36, sumAbs is 12 so min > upper prunes the state even though 6*6 reaches 36. This causes the search to return empty results for valid targets above the sum of absolute values, so any inputs where the target exceeds sumAbs can be incorrectly skipped.
Useful? React with 👍 / 👎.