Try several operator counts
This commit is contained in:
@@ -44,16 +44,18 @@ 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) {
|
||||
merge_expression(&digits, &operators, equals_idx, &mut trial);
|
||||
if let Ok(tokens) = lexer(&trial) {
|
||||
if let Ok(expressions) = parse(&tokens) {
|
||||
if are_valid_expressions(&expressions) {
|
||||
combinations.push(trial.clone());
|
||||
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) {
|
||||
if are_valid_expressions(&expressions) {
|
||||
combinations.push(trial.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
trial.clear();
|
||||
}
|
||||
trial.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user