2025-12-07 07:58:26 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/StevanFreeborn/advent-of-code-2025/internal/file"
|
2025-12-07 21:25:34 -06:00
|
|
|
"github.com/StevanFreeborn/advent-of-code-2025/internal/grid"
|
|
|
|
|
"github.com/StevanFreeborn/advent-of-code-2025/internal/move"
|
2025-12-07 07:58:26 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const PaperRollCharacter = "@"
|
|
|
|
|
|
|
|
|
|
func SolvePartOne(filePath string) int {
|
|
|
|
|
input := file.ReadAllLines(filePath)
|
2025-12-07 21:25:34 -06:00
|
|
|
grid := grid.From(input)
|
2025-12-07 07:58:26 -06:00
|
|
|
|
|
|
|
|
total := 0
|
|
|
|
|
|
2025-12-07 21:33:11 -06:00
|
|
|
for position := range grid.Positions() {
|
|
|
|
|
value := grid.GetValueAt(position)
|
2025-12-07 07:58:26 -06:00
|
|
|
|
2025-12-07 21:33:11 -06:00
|
|
|
if value != PaperRollCharacter {
|
|
|
|
|
continue
|
|
|
|
|
}
|
2025-12-07 07:58:26 -06:00
|
|
|
|
2025-12-07 21:33:11 -06:00
|
|
|
sameNeighbors := grid.GetSameNeighborsOf(position, move.AllDirections)
|
2025-12-07 07:58:26 -06:00
|
|
|
|
2025-12-07 21:33:11 -06:00
|
|
|
if len(sameNeighbors) < 4 {
|
|
|
|
|
total++
|
2025-12-07 07:58:26 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return total
|
|
|
|
|
}
|