day7, part2
This commit is contained in:
parent
b1110f2b6c
commit
342dd2982a
1 changed files with 6 additions and 8 deletions
|
@ -3,7 +3,7 @@ use std::collections::HashSet;
|
|||
use winnow::{
|
||||
PResult, Parser,
|
||||
ascii::{dec_uint, newline, space1},
|
||||
combinator::{eof, opt, separated, separated_pair, seq},
|
||||
combinator::{opt, separated, separated_pair, seq},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
|
@ -86,7 +86,7 @@ fn check(equation: &Equation, pt2: bool) -> bool {
|
|||
}
|
||||
if process_top {
|
||||
let _ = q.pop();
|
||||
if cur_val == target {
|
||||
if cur_val == target && cur_idx == (equation.factors.len() - 1) {
|
||||
return true;
|
||||
}
|
||||
processed.insert(current);
|
||||
|
@ -112,10 +112,8 @@ fn parse_equation(input: &mut &str) -> PResult<Equation> {
|
|||
}
|
||||
|
||||
fn parse(input: &str) -> Vec<Equation> {
|
||||
let (equations, _): (Vec<Equation>, _) = seq!(
|
||||
separated(1.., parse_equation, newline),
|
||||
seq!(opt(newline), opt(eof))
|
||||
)
|
||||
let (equations, _): (Vec<Equation>, _) =
|
||||
seq!(separated(1.., parse_equation, newline), opt(newline))
|
||||
.parse(input)
|
||||
.unwrap();
|
||||
equations
|
||||
|
|
Loading…
Reference in a new issue