Skip to content

Fix HittingSet solver IndexOutOfRange / missed-item loop bound#311

Merged
wrigjl merged 1 commit into
CSharpAPIfrom
bugfix/hittingset-solver-loop-bound
Jun 19, 2026
Merged

Fix HittingSet solver IndexOutOfRange / missed-item loop bound#311
wrigjl merged 1 commit into
CSharpAPIfrom
bugfix/hittingset-solver-loop-bound

Conversation

@Trosper3

Copy link
Copy Markdown
Contributor

The inner loop iterated hittingSet.subSets.Count() + 1 times while indexing into items (the universalSet). When the universal set size differs from subsets count the loop either crashes with IndexOutOfRangeException or stops before processing every candidate. The possibleSolution list is already sized by items.Count, so use that as the bound.

The inner loop iterated hittingSet.subSets.Count() + 1 times while
indexing into items (the universalSet). When the universal set size
differs from subsets count the loop either crashes with
IndexOutOfRangeException or stops before processing every candidate.
The possibleSolution list is already sized by items.Count, so use
that as the bound.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wrigjl

wrigjl commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

When you find bugs like this, see if you can create a unit test that fails before your fix and succeeds afterwards.

@wrigjl wrigjl merged commit d66fd93 into CSharpAPI Jun 19, 2026
6 checks passed
@wrigjl wrigjl deleted the bugfix/hittingset-solver-loop-bound branch June 19, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants