Day 8
This commit is contained in:
25
day08/common/forest.go
Normal file
25
day08/common/forest.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
)
|
||||
|
||||
type Tree int
|
||||
|
||||
type Forest [][]Tree
|
||||
|
||||
|
||||
func Parse(scanner bufio.Scanner) Forest {
|
||||
forest := Forest{}
|
||||
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
forestRow := make([]Tree, len(line))
|
||||
for i, character := range line {
|
||||
forestRow[i] = Tree(character - '0')
|
||||
}
|
||||
forest = append(forest, forestRow)
|
||||
}
|
||||
|
||||
return forest
|
||||
}
|
||||
Reference in New Issue
Block a user