pub fn exhaustive_combined_k_compositions(
    n_min: usize,
    n_max: usize,
    k: usize
) -> ExhaustiveCombinedKCompositions 
Expand description

Given $n_\text{min}$, $n_\text{max}$, and $k$, generates all length-$k$ Vecs of positive usizes whose sum is in the closed interval $[n_\text{min}, n_\text{max}]$.

The output length is $$ \sum_{n=n_\text{min}}^{n_\text{max}} \binom{n-1}{k-1}. $$

§Panics

Panics if $n_\text{min} > n_\text{max}$.

§Examples

use itertools::Itertools;
use malachite_base::vecs::exhaustive::exhaustive_combined_k_compositions;

let xss = exhaustive_combined_k_compositions(4, 6, 3).collect_vec();
assert_eq!(
    xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
    &[
        &[1, 1, 2], &[1, 1, 3], &[1, 2, 1], &[1, 1, 4], &[2, 1, 1], &[1, 2, 2], &[1, 3, 1],
        &[1, 2, 3], &[2, 1, 2], &[1, 3, 2], &[2, 2, 1], &[3, 1, 1], &[1, 4, 1], &[2, 1, 3],
        &[2, 2, 2], &[2, 3, 1], &[3, 1, 2], &[3, 2, 1], &[4, 1, 1]
    ]
);