Try several operator counts

main
Clément FRÉVILLE 2 years ago
parent 0051069428
commit 2e862bdf58

@ -44,7 +44,8 @@ pub fn generate_valid_combinations(hand: &Hand) -> Vec<Vec<Tile>> {
// Then try to place the equals sign at each possible position
// Since equality is commutative, we only need to try half of the positions
for equals_idx in 0..(nb_digits / 2) {
for operators in operators.iter().permutations(nb_digits - 2) {
for nb_operators in 0..=(nb_digits - 2) {
for operators in operators.iter().permutations(nb_operators) {
merge_expression(&digits, &operators, equals_idx, &mut trial);
if let Ok(tokens) = lexer(&trial) {
if let Ok(expressions) = parse(&tokens) {
@ -58,6 +59,7 @@ pub fn generate_valid_combinations(hand: &Hand) -> Vec<Vec<Tile>> {
}
}
}
}
combinations
}

Loading…
Cancel
Save