Function malachite_base::strings::exhaustive::lex_fixed_length_strings
source · pub fn lex_fixed_length_strings(
len: u64,
) -> StringsFromCharVecs<LexFixedLengthVecsFromSingle<ExhaustiveChars>> ⓘ
Expand description
Generates all [String
]s of a given length in lexicographic order.
The order is lexicographic with respect to the order of exhaustive_chars
, which is not the
default lexicographic order for char
s. (For example, the first characters are not control
characters, but lowercase Latin letters.) If you want the default char
order, use
lex_fixed_length_strings_using_chars(len, chars_increasing())
.
The output length is $1112064^n$, where $n$ is len
.
If len
is 0, the output consists of one empty [String
].
§Complexity per iteration
$T(i, n) = O(n)$
$M(i, n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is len
.
§Examples
use itertools::Itertools;
use malachite_base::strings::exhaustive::lex_fixed_length_strings;
let ss = lex_fixed_length_strings(2).take(20).collect_vec();
assert_eq!(
ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),
&[
"aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj", "ak", "al", "am", "an",
"ao", "ap", "aq", "ar", "as", "at"
]
);