package one import ( "bufio" "io" "strconv" ) func parseLines(r io.Reader) ([]block, error) { var blocks []block scanner := bufio.NewScanner(r) for scanner.Scan() { line := scanner.Text() for i := 0; i < len(line); i += 2 { var free int if i < len(line)-1 { free = mustConv(string(line[i+1])) } blocks = append(blocks, block{mustConv(string(line[i])), free}) } } if err := scanner.Err(); err != nil { return []block{}, err } return blocks, nil } func mustConv(s string) int { n, err := strconv.Atoi(s) if err != nil { panic(err) } return n }