package main import ( "fmt" "strings" "git.z1glr.de/advent-of-code-2025/pkg/aoc" ) type Schematic struct { rows []string timelines [][]int splits int } func (s *Schematic) Calculate() { startIndex := strings.Index(s.rows[0], "S") s.timelines = make([][]int, len(s.rows)) for ii, rr := range s.rows { s.timelines[ii] = make([]int, len(rr)) } s.timelines[0][startIndex] = 1 s.CalculateRow(0) } func (s *Schematic) CalculateRow(i int) { if i == len(s.rows)-1 { return } for ii, count := range s.timelines[i] { switch s.rows[i+1][ii] { case byte('^'): s.timelines[i+1][ii-1] += count s.timelines[i+1][ii+1] += count if s.timelines[i][ii] > 0 { s.splits++ } default: s.timelines[i+1][ii] += count } } s.CalculateRow(i + 1) } func do(test bool) (int, int) { schematic := Schematic{ rows: aoc.ReadFileRows(test), } schematic.Calculate() timelineCount := 0 for _, cc := range schematic.timelines[len(schematic.timelines)-1] { timelineCount += cc } fmt.Println(schematic.splits) fmt.Println(timelineCount) return schematic.splits, timelineCount } func main() { if r1, r2 := do(true); r1 == 21 && r2 == 40 { do(false) } }