package main import ( "bufio" _ "embed" "fmt" "sort" "strings" aoc "go.sour.is/advent-of-code-2023" ) // var log = aoc.Log func main() { aoc.MustResult(aoc.Runner(run)) } type result struct { valuePT1 int valuePT2 int } func (r result) String() string { return fmt.Sprintf("%#v", r) } func run(scan *bufio.Scanner) (*result, error) { m := NewMap() for scan.Scan() { text := scan.Text() m.readLine(text) } // solution9 := m.expand(9).sumPaths() // fmt.Println(solution9) // solution99 := m.expand(99).sumPaths() // fmt.Println(solution99) return &result{ valuePT1: m.expand(1).sumPaths(), valuePT2: m.expand(999_999).sumPaths(), }, nil } type Map struct { rows int cols int emptyRows map[int]bool emptyCols map[int]bool *aoc.List[rune] } func NewMap() *Map { return &Map{ emptyRows: make(map[int]bool), emptyCols: make(map[int]bool), List: aoc.NewList[rune](nil), } } func (m *Map) String() string { buf := &strings.Builder{} fmt.Fprintf(buf, "Map size %d x %d\n", m.rows, m.cols) fmt.Fprintln(buf, "empty rows:", all(m.emptyRows)) fmt.Fprintln(buf, "empty cols:", all(m.emptyCols)) n := m.Head() for n != nil { fmt.Fprintln(buf, toXY(n.Position(), m.cols), n.String()) n = n.Next() } for row:=0; row