package one import ( "bufio" "io" "regexp" log "github.com/sirupsen/logrus" ) var reStartPos = regexp.MustCompile(`0`) func parseLines(r io.Reader) (*graph, error) { graph := newGrid() var linecount int scanner := bufio.NewScanner(r) for scanner.Scan() { line := scanner.Text() graph.data = append(graph.data, line) for _, m := range reStartPos.FindAllStringIndex(line, -1) { graph.startPositions = append( graph.startPositions, point{x: m[0], y: linecount}, ) } linecount++ } log.Debug(graph.startPositions) if err := scanner.Err(); err != nil { return nil, err } return graph, nil } func replaceAtIndex(s string, r rune, i int) string { out := []rune(s) out[i] = r return string(out) }