day 4 cleanup
This commit is contained in:
parent
b04ae5c077
commit
ce0ccaaafa
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user