mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2026-04-09 02:23:36 +00:00
pass graph as last arg
This commit is contained in:
@@ -24,7 +24,7 @@ func Solve(buf []byte) (int, error) {
|
||||
}
|
||||
graph.update(robots)
|
||||
|
||||
numNeighbours := evaluateNeighbours(graph, robots)
|
||||
numNeighbours := evaluateNeighbours(robots, graph)
|
||||
if numNeighbours > max {
|
||||
max = numNeighbours
|
||||
maxAtSecond = i
|
||||
@@ -34,15 +34,15 @@ func Solve(buf []byte) (int, error) {
|
||||
return maxAtSecond, nil
|
||||
}
|
||||
|
||||
func evaluateNeighbours(graph *graph, robots []*robot) int {
|
||||
func evaluateNeighbours(robots []*robot, g *graph) int {
|
||||
var numNeighbours int
|
||||
for _, robot := range robots {
|
||||
for _, n := range neighbours(robot.position) {
|
||||
if graph.isOutOfBounds(n) {
|
||||
if g.isOutOfBounds(n) {
|
||||
continue
|
||||
}
|
||||
|
||||
if graph.valueAt(n) > 0 {
|
||||
if g.valueAt(n) > 0 {
|
||||
numNeighbours++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user