remove unnecessary assignments

This commit is contained in:
onyx-and-iris 2025-01-07 17:23:33 +00:00
parent fd057f88ed
commit 2b675af081
2 changed files with 6 additions and 14 deletions

View File

@ -19,18 +19,14 @@ func Solve(buf []byte) (int, error) {
for _, equation := range equations { for _, equation := range equations {
go func() { go func() {
var total int var total int
if res, ok := next(equation.target, equation.operands, total, sumOp); ok { res, _ := next(equation.target, equation.operands, total, sumOp)
sumChan <- res sumChan <- res
return
}
sumChan <- 0
}() }()
} }
var sum int var sum int
for range conc { for range conc {
res := <-sumChan sum += <-sumChan
sum += res
} }
return sum, nil return sum, nil

View File

@ -20,18 +20,14 @@ func Solve(buf []byte) (int, error) {
for _, equation := range equations { for _, equation := range equations {
go func() { go func() {
var total int var total int
if res, ok := next(equation.target, equation.operands, total, joinOp); ok { res, _ := next(equation.target, equation.operands, total, joinOp)
sumChan <- res sumChan <- res
return
}
sumChan <- 0
}() }()
} }
var sum int var sum int
for range conc { for range conc {
res := <-sumChan sum += <-sumChan
sum += res
} }
return sum, nil return sum, nil