2025-12-07 07:58:26 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2025-12-07 21:25:34 -06:00
|
|
|
"fmt"
|
|
|
|
|
|
2025-12-07 07:58:26 -06:00
|
|
|
"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"
|
|
|
|
|
"github.com/StevanFreeborn/advent-of-code-2025/internal/position"
|
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:25:34 -06:00
|
|
|
for row := range grid.NumberOfRows() {
|
|
|
|
|
for column := range grid.NumberOfColumns() {
|
|
|
|
|
currentPosition := position.From(row, column)
|
|
|
|
|
value := grid.GetValueAt(currentPosition)
|
2025-12-07 07:58:26 -06:00
|
|
|
|
|
|
|
|
if value != PaperRollCharacter {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-07 21:25:34 -06:00
|
|
|
sameNeighbors := grid.GetSameNeighborsOf(currentPosition, move.AllDirections)
|
2025-12-07 07:58:26 -06:00
|
|
|
|
2025-12-07 21:25:34 -06:00
|
|
|
if row == 0 && column == 3 {
|
|
|
|
|
fmt.Println(sameNeighbors)
|
2025-12-07 07:58:26 -06:00
|
|
|
}
|
|
|
|
|
|
2025-12-07 21:25:34 -06:00
|
|
|
if len(sameNeighbors) < 4 {
|
2025-12-07 07:58:26 -06:00
|
|
|
total++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return total
|
|
|
|
|
}
|