Documentation
¶
Overview ¶
Package glue contains the glue code to link together the different days' solvers.
The expected way to use this package is:
- Have your daily solver packages not export anything, but just have init functions that call this package's `RegisterFoo` functions.
- For each year, have a `yNNNN` package that blank-imports each day to pull them in.
- To build the standard omnibus binary, blank-import each year, and call `Main`.
Index ¶
- func Ints(in ...int) (out []string)
- func Main()
- func RegisterPlotter(year, day int, suffix string, p Plotter, examples map[string]string)
- func RegisterSolver(year, day int, s Solver)
- func RunBenchmarks(b *testing.B, testRoot string, year int)
- func RunTests(t *testing.T, testRoot string, year int)
- func Solve(year, day int, input io.Reader) ([]string, error)
- func SolveFile(year, day int, path string) ([]string, error)
- func WithParser[PF ~func(I) (O, error), SF ~func([]O) ([]string, error), I, O any](pf PF, sf SF) func([]I) ([]string, error)
- type ChunkPlotter
- type ChunkSolver
- type FixedLevelSolver
- type GenericSolver
- type IntSolver
- type LevelSolver
- type LinePlotter
- type LineSolver
- type Plotter
- type RegexpSolver
- type Solver
- type TestCase
- type YearDay
- type YearDaySuffix
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterPlotter ¶
RegisterPlotter makes a plotter known to the glue code as the nominated plotter of the given day.
func RegisterSolver ¶
RegisterSolver makes a solver known to the glue code as the nominated solver of the given day. This function is expected to be called from an `init` func.
Types ¶
type ChunkPlotter ¶
type ChunkSolver ¶
ChunkSolver wraps a solution that wants the blank-line-separated paragraphs of the input as strings.
type FixedLevelSolver ¶
type FixedLevelSolver func(*util.FixedLevel) ([]string, error)
FixedLevelSolver wraps a solution that wants the lines of the input converted to the trimmed-down `util.FixedLevel` type.
type GenericSolver ¶
GenericSolver wraps a solution function that does all the work itself.
type IntSolver ¶
IntSolver wraps a solution that wants the input read in as a list of decimal integers. The separators can be any non-digit characters.
type LevelSolver ¶
LevelSolver wraps a solution that wants the lines of the input converted to a 2D level structure.
type LinePlotter ¶
LinePlotter wraps a plotter that wants the lines of the input as strings.
type LineSolver ¶
LineSolver wraps a solution that wants the lines of the input as strings.
type Plotter ¶
Plotter represents a function capable of turning an AoC puzzle input to a GraphViz dot graph.
type RegexpSolver ¶
RegexpSolver wraps a solution that wants to match a single regular expression to each of the input lines. The solver is called with a slice of slices of all submatches. Note that this excludes the full pattern match that is typically included in regexp match outputs.
type Solver ¶
type Solver interface { // Solves the puzzle by reading the given input, and producing a set of output lines. Solve(r io.Reader) ([]string, error) }
Solver represents a function capable of solving one of the AoC puzzles.
type TestCase ¶
func FindAllTests ¶
type YearDay ¶
type YearDay struct{ Year, Day int }
YearDay names an AoC puzzle by the event year (2015+) and puzzle day (1-25).
type YearDaySuffix ¶
YearDaySuffix names a plotter by the event year (2015+), puzzle day (1-25) and an optional disambiguation suffix.