chore: make reduce more iter.Seq
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
aoc "go.sour.is/advent-of-code"
|
||||
@@ -62,7 +63,7 @@ func run(scan *bufio.Scanner) (*result, error) {
|
||||
func(i int, v int, counts [3]int) [3]int {
|
||||
counts[v]++
|
||||
return counts
|
||||
}, [3]int{}, maps.Values(memo)...)
|
||||
}, [3]int{}, slices.Values(maps.Values(memo)))
|
||||
|
||||
// fmt.Println(i, counts)
|
||||
i = 1_000_000_000 - (1_000_000_000-counts[0]-counts[1])%counts[2]
|
||||
|
||||
@@ -32,14 +32,14 @@ func run(scan *bufio.Scanner) (*result, error) {
|
||||
r.valuePT1 = aoc.Reduce(func(i int, t string, sum int) int {
|
||||
sum += hash(t)
|
||||
return sum
|
||||
}, 0, ops...)
|
||||
}, 0, slices.Values(ops))
|
||||
}
|
||||
|
||||
var boxen boxes
|
||||
|
||||
boxen = aoc.Reduce(func(i int, op string, b boxes) boxes {
|
||||
return b.Op(op)
|
||||
}, boxen, ops...)
|
||||
}, boxen, slices.Values(ops))
|
||||
|
||||
r.valuePT2 = boxen.Sum()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user