fn is_message_valid_using_recursive_descent_wrapper(r: &RulesMap, m: &str) -> bool {
    let mut rules_applied = Vec::<RuleId>::new();
    let mut rules_left = Vec::<RuleId>::new();
    let (is_match, final_matched_idx) = is_message_valid_using_recursive_descent(
        m,
        r,
        0,
        0,
        0,
        &mut rules_applied,
        &mut rules_left,
    );
    if !is_match {
        return false;
    }
    final_matched_idx == m.len()
}
// This won't work for part 2 (and it's surprising that it works for part 1)
// because it doesn't actually consider all possibilities.
// That's because check_if_matches_sequence returns early when it finds a candidate
// combination that matches some prefix. But it's possible that the suffix might
// not be matched in which case the code won't try to consider other combinations
// that happened after the early return.
// is_message_valid_using_list_of_suffixes_wrapper takes to check all possible
// branches.
This won't work for part 2 (and it's surprising that it works for part 1)
because it doesn't actually consider all possibilities.
That's because check_if_matches_sequence returns early when it finds a candidate
combination that matches some prefix. But it's possible that the suffix might
not be matched in which case the code won't try to consider other combinations
that happened after the early return.
is_message_valid_using_list_of_suffixes_wrapper takes to check all possible
branches.
This won ' t work for part 2 ( and it ' s surprising that it works for part 1 ) because it doesn ' t actually consider all possibilities . That ' s because check_if_matches_sequence returns early when it finds a candidate combination that matches some prefix . But it ' s possible that the suffix might not be matched in which case the code won ' t try to consider other combinations that happened after the early return . is_message_valid_using_list_of_suffixes_wrapper takes to check all possible branches .
fn is_message_valid_using_recursive_descent_wrapper(r: &RulesMap, m: &str) -> bool {
    let mut rules_applied = Vec::<RuleId>::new();
    let mut rules_left = Vec::<RuleId>::new();
    let (is_match, final_matched_idx) = is_message_valid_using_recursive_descent(
        m,
        r,
        0,
        0,
        0,
        &mut rules_applied,
        &mut rules_left,
    );
    if !is_match {
        return false;
    }
    final_matched_idx == m.len()
}
fn is_message_valid_using_recursive_descent_wrapper ( r : & RulesMap , m : & str ) -> bool { let mut rules_applied = Vec :: < RuleId > :: new ( ) ; let mut rules_left = Vec :: < RuleId > :: new ( ) ; let ( is_match , final_matched_idx ) = is_message_valid_using_recursive_descent ( m , r , 0 , 0 , 0 , & mut rules_applied , & mut rules_left , ) ; if ! is_match { return false ; } final_matched_idx == m . len ( ) }
This won't work for part 2 (and it's surprising that it works for part 1)
because it doesn't actually consider all possibilities.
This won ' t work for part 2 ( and it ' s surprising that it works for part 1 ) because it doesn ' t actually consider all possibilities .
r
&RulesMap
m
&str
r
&RulesMap
m
&str