Files
advent-of-code-2025/cmd/04/main.go
T

43 lines
901 B
Go
Raw Normal View History

2025-12-07 07:58:26 -06:00
package main
import (
"fmt"
2025-12-07 07:58:26 -06:00
"github.com/StevanFreeborn/advent-of-code-2025/internal/file"
"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)
grid := grid.From(input)
2025-12-07 07:58:26 -06:00
total := 0
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
}
sameNeighbors := grid.GetSameNeighborsOf(currentPosition, move.AllDirections)
2025-12-07 07:58:26 -06:00
if row == 0 && column == 3 {
fmt.Println(sameNeighbors)
2025-12-07 07:58:26 -06:00
}
if len(sameNeighbors) < 4 {
2025-12-07 07:58:26 -06:00
total++
}
}
}
return total
}