Open densmojd opened 11 months ago
All modified lines are covered by tests :white_check_mark:
Comparison is base (
ac70c46
) 96.97% compared to head (3b3446c
) 97.13%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR provides functionality for generating compositions, specifically two different types of compositions:
This PR partially addresses #101, although the composition in that case seems to be the union of all compositions of n into k parts (as defined above) over all possible k (k <= n).
The algorithm for weak compositions relies on the relationship between weak compositions and combinations (I think it comes from TAoCP, but I've long since lost the reference) and uses the existing
Combinations
iterator. The algorithm for compositions relies on the fact that adding one to each element of a weak composition of n into k parts yields a composition of n + k into k parts.