From 2b675af0814d3ca8f7ddf1ec57e101e88cf4cfe5 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Tue, 7 Jan 2025 17:23:33 +0000 Subject: [PATCH] remove unnecessary assignments --- day-07/internal/one/solve.go | 10 +++------- day-07/internal/two/solve.go | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) 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