diff --git a/day-07/internal/one/solve.go b/day-07/internal/one/solve.go index 06385e4..0cde008 100644 --- a/day-07/internal/one/solve.go +++ b/day-07/internal/one/solve.go @@ -19,18 +19,14 @@ func Solve(buf []byte) (int, error) { for _, equation := range equations { go func() { var total int - if res, ok := next(equation.target, equation.operands, total, sumOp); ok { - sumChan <- res - return - } - sumChan <- 0 + res, _ := next(equation.target, equation.operands, total, sumOp) + sumChan <- res }() } var sum int for range conc { - res := <-sumChan - sum += res + sum += <-sumChan } return sum, nil diff --git a/day-07/internal/two/solve.go b/day-07/internal/two/solve.go index 5a27e03..811ccd7 100644 --- a/day-07/internal/two/solve.go +++ b/day-07/internal/two/solve.go @@ -20,18 +20,14 @@ func Solve(buf []byte) (int, error) { for _, equation := range equations { go func() { var total int - if res, ok := next(equation.target, equation.operands, total, joinOp); ok { - sumChan <- res - return - } - sumChan <- 0 + res, _ := next(equation.target, equation.operands, total, joinOp) + sumChan <- res }() } var sum int for range conc { - res := <-sumChan - sum += res + sum += <-sumChan } return sum, nil