Documentation ¶
Index ¶
- type Context
- type Day
- func (d *Day[Input, Cache]) Day() int
- func (d *Day[Input, Cache]) Run(ctx context.Context, saveOutput bool)
- func (d *Day[Input, Cache]) Test(t *testing.T, part1TestInput string, part1ExpectedAnswer int, ...)
- func (d *Day[Input, Cache]) TestContext(t *testing.T, partNum int) *Context
- func (d *Day[Input, Cache]) TestPart1(t *testing.T, input string, expectedAnswer int)
- func (d *Day[Input, Cache]) TestPart2(t *testing.T, input string, expectedAnswer int)
- func (d *Day[Input, Cache]) WithExpectedAnswers(part1, part2 int) *Day[Input, Cache]
- func (d *Day[Input, Cache]) WithPart1KnownMax(max int) *Day[Input, Cache]
- func (d *Day[Input, Cache]) WithPart2KnownMax(max int) *Day[Input, Cache]
- type Part
- type RunnableDay
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context is the runner
func (*Context) OutputFile ¶
OutputFile returns the path to the output file for this day and part
func (*Context) SaveOutput ¶
SaveOutput returns true if the output should be saved to a file
type Day ¶
type Day[Input, Cache any] struct { // contains filtered or unexported fields }
Day represents a day of the advent of code
func NewDay ¶
func NewDay[Input any](day int, parser func([]byte) (Input, error), part1, part2 Part[Input]) *Day[Input, Input]
NewDay returns a day which is parsed as a whole initially, and then the parsed data is given to each part.
See NewStreamingDay for a stream processing version
func NewStreamingDay ¶
func NewStreamingDay[Input any](day int, parser func([]byte) stream.Stream[Input], part1, part2 Part[stream.Stream[Input]]) *Day[stream.Stream[Input], []Input]
NewStreamingDay creates a day which takes a parser to convert the input bytes into a stream of inputs, which the part 1 and part 2 functions can then use.
func (*Day[Input, Cache]) Run ¶
Run executes the given parts with the given input
If an error is encountered, the program will exit with a non-zero exit code
func (*Day[Input, Cache]) Test ¶
func (d *Day[Input, Cache]) Test(t *testing.T, part1TestInput string, part1ExpectedAnswer int, part2estInput string, part2ExpectedAnswer int)
Test runs the given parts with the given input and asserts the answers
func (*Day[Input, Cache]) TestContext ¶
TestContext creates a context for testing with
func (*Day[Input, Cache]) TestPart1 ¶
TestPart1 runs the given part 1 with the given input and asserts the answer
func (*Day[Input, Cache]) TestPart2 ¶
TestPart2 runs the given part 2 with the given input and asserts the answer
func (*Day[Input, Cache]) WithExpectedAnswers ¶
func (*Day[Input, Cache]) WithPart1KnownMax ¶
func (*Day[Input, Cache]) WithPart2KnownMax ¶
type Part ¶
Part represents a function which given the input will return the answer for that part of the day