mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 06:10:47 +00:00
remove unnecessary assignments
This commit is contained in:
parent
fd057f88ed
commit
2b675af081
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user