mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-10 06:40:47 +00:00
30 lines
466 B
Go
30 lines
466 B
Go
package one
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"strings"
|
|
)
|
|
|
|
func parseLines(r io.Reader) (*graph, error) {
|
|
graph := newGraph()
|
|
|
|
count := 0
|
|
scanner := bufio.NewScanner(r)
|
|
for scanner.Scan() {
|
|
line := scanner.Text()
|
|
indx := strings.Index(line, "^")
|
|
if indx != -1 {
|
|
graph.startPoint = point{coords{indx, count}, N}
|
|
}
|
|
graph.data = append(graph.data, scanner.Text())
|
|
count++
|
|
}
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return graph, nil
|
|
}
|