day 4 cleanup

This commit is contained in:
Gabriel Bizdoc 2025-12-04 09:11:40 +02:00
parent b04ae5c077
commit ce0ccaaafa
No known key found for this signature in database
GPG Key ID: 3F0EDAECA5BE9ED9

View File

@ -11,6 +11,7 @@ const Day4PaperRoll = '@'
func Day4Part1(r io.Reader, l Logger) (any, error) {
// 4 rolls in 8 adjacent positions
const maxAdjacentRolls = 4
var accessibleRolls int
g, err := geometry.ReaderToByteGrid(r)
@ -30,7 +31,7 @@ func Day4Part1(r io.Reader, l Logger) (any, error) {
}
}
if count <= 4 {
if count <= maxAdjacentRolls {
accessibleRolls += 1
}
}
@ -40,6 +41,7 @@ func Day4Part1(r io.Reader, l Logger) (any, error) {
func Day4Part2(r io.Reader, l Logger) (any, error) {
// 4 rolls in 8 adjacent positions
const maxAdjacentRolls = 4
var totalRemovedRolls int
g, err := geometry.ReaderToByteGrid(r)
@ -61,7 +63,7 @@ func Day4Part2(r io.Reader, l Logger) (any, error) {
}
}
if count <= 4 {
if count <= maxAdjacentRolls {
removedRolls += 1
g.Set(c, '.') // remove grid
}