Skip to content

intComposition with a stars and bars implementation - #396

Open
robstoll wants to merge 1 commit into
mainfrom
feature/intComposition
Open

intComposition with a stars and bars implementation#396
robstoll wants to merge 1 commit into
mainfrom
feature/intComposition

Conversation

@robstoll

@robstoll robstoll commented Aug 8, 2026

Copy link
Copy Markdown
Member

I confirm that I have read the Contributor Agreement v1.1, agree to be bound on them and confirm that my contribution is compliant.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new ArbExtensionPoint.intComposition(total, numberOfParts, minPart) generator based on a stars-and-bars approach, plus accompanying tests to validate generated compositions.

Changes:

  • Introduce intComposition generator for producing integer compositions with a per-part minimum.
  • Extend ArbNumberTest to cover intComposition and add/expand numeric bound tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/kotlin/com/tegonal/variist/generators/arbNumber.kt Adds intComposition generator and validation logic.
src/test/kotlin/com/tegonal/variist/generators/ArbNumberTest.kt Adds intComposition tests and additional bound tests for number arbs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +198 to +202
// We treat this as a stars and bars problem, so minPart can also be thought of the min. number of stars in a part
val totalMinStars = numberOfParts * minPart
require(totalMinStars <= total) {
"numberOfParts ($numberOfParts) * minPart ($minPart) must be less than or equal to total ($total)"
}
// including the minPart requirement. Since we moved the min stars requirement out of remainingStars,
// a bar could also be at position 0, i.e. the first part wouldn't get any remaining star.
// Due to this we introduce a virtual bar -1 at the beginning so that we can use the same formula
// also for the first part. Likewise, we add totalStarsAndBars as virtual bar at the end. Then
Comment on lines +199 to +200
@Test
fun intComposition_total8_parts4_minPart2_everyPart1() {
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