27 lines
775 B
Rust
27 lines
775 B
Rust
|
|
use std::collections::HashSet;
|
||
|
|
|
||
|
|
fn create_operator_set_recurse(
|
||
|
|
operators_permutation_set: &mut HashSet<Vec<bool>>,
|
||
|
|
operators: Vec<bool>,
|
||
|
|
) {
|
||
|
|
operators_permutation_set.insert(operators.clone());
|
||
|
|
if !operators.contains(&false) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
for i in 0..operators.len() {
|
||
|
|
if operators[i] {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
let mut new_operators = operators.clone();
|
||
|
|
new_operators[i] = true;
|
||
|
|
create_operator_set_recurse(operators_permutation_set, new_operators);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn create_operator_set(num_of_operators: usize) -> HashSet<Vec<bool>> {
|
||
|
|
let mut operator_sets: HashSet<Vec<bool>> = HashSet::new();
|
||
|
|
create_operator_set_recurse(&mut operator_sets, vec![false; num_of_operators]);
|
||
|
|
operator_sets
|
||
|
|
}
|