Function malachite_base::vecs::exhaustive::lex_unique_vecs_min_length
source · pub fn lex_unique_vecs_min_length<I: Clone + Iterator>(
min_length: u64,
xs: I,
) -> LexUniqueVecs<I> ⓘ
Expand description
Generates Vec
s with a mininum length, with elements from a single iterator, such that each
Vec
has no repeated elements.
The Vec
s are ordered lexicographically with respect to the order of the element iterator.
The source iterator should not repeat any elements, but this is not enforced.
The iterator should be finite; if it is infinite, only prefixes of the iterator will be generated.
If the input iterator is infinite, the output length is also infinite.
If the input iterator length is $n$ and the min_length
is $\ell$, the output length is
$$
\sum_{i=\ell}^n \frac{n!}{k!}.
$$
§Examples
use itertools::Itertools;
use malachite_base::vecs::exhaustive::lex_unique_vecs_min_length;
let xss = lex_unique_vecs_min_length(2, 1..=4).take(20).collect_vec();
assert_eq!(
xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
&[
&[1, 2][..],
&[1, 2, 3],
&[1, 2, 3, 4],
&[1, 2, 4],
&[1, 2, 4, 3],
&[1, 3],
&[1, 3, 2],
&[1, 3, 2, 4],
&[1, 3, 4],
&[1, 3, 4, 2],
&[1, 4],
&[1, 4, 2],
&[1, 4, 2, 3],
&[1, 4, 3],
&[1, 4, 3, 2],
&[2, 1],
&[2, 1, 3],
&[2, 1, 3, 4],
&[2, 1, 4],
&[2, 1, 4, 3]
]
);