21 lines
373 B
Go
21 lines
373 B
Go
package day03
|
|
|
|
func checkSlope(rows [][]byte, ySpeed int, xSpeed int) int {
|
|
rowLen := len(rows[0])
|
|
key := 0
|
|
counter := 0
|
|
|
|
for i := 0; i < len(rows); i += ySpeed {
|
|
// Check if this column on this row is a tree ASCII Char 35 (#)
|
|
// Use modulo to "wrap" the map.
|
|
if rows[i][key%rowLen] == 35 {
|
|
counter++
|
|
}
|
|
|
|
// Step right
|
|
key += xSpeed
|
|
}
|
|
|
|
return counter
|
|
}
|