mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 22:30: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 {
|
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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user