Documentation
¶
Index ¶
- Constants
- Variables
- func AbsI(x int) int
- func AllCombinations[S ~[]E, E any](s S) iter.Seq[[]E]
- func Atoi(s string) int
- func Combinations[S ~[]E, E any](s S) iter.Seq[[]E]
- func FirstMaxIndex(s []int) (int, int)
- func FirstMinIndex(s []int) (int, int)
- func MultSlice(s []int) int
- func MultiInput[R1, R2 any](i Input, parseInput1 func(i Input) R1, parseInput2 func(i Input) R2) (R1, R2)
- func ResultF64(f float64) string
- func ResultI(i int) string
- func ResultS(s []string) string
- func ResultSI(s []int) string
- func SumSlice(s []int) int
- type Cache
- type Client
- type Counter
- type CounterKey
- type DefaultCache
- type DefaultClient
- type Grid
- func (g Grid[E]) Around(p Point) iter.Seq2[Point, E]
- func (g Grid[E]) At(p Point) E
- func (g Grid[E]) AtXY(x int, y int) E
- func (g Grid[E]) IterAllColumn(y int) iter.Seq2[Point, E]
- func (g Grid[E]) IterAllLine(x int) iter.Seq2[Point, E]
- func (g Grid[E]) IterColumn(y int, xMin int, xMax int) iter.Seq2[Point, E]
- func (g Grid[E]) IterLine(x int, yMin int, yMax int) iter.Seq2[Point, E]
- func (g Grid[E]) LenX() int
- func (g Grid[E]) LenY() int
- func (g Grid[E]) MaxX() int
- func (g Grid[E]) MaxY() int
- func (g Grid[E]) Points() iter.Seq2[Point, E]
- func (g Grid[E]) Set(p Point, v E)
- func (g Grid[E]) String() string
- type Input
- func (i Input) Content() string
- func (i Input) Delimiter(d string) Input
- func (i Input) Lines() iter.Seq[String]
- func (i Input) Rotate() []String
- func (i Input) SingleLine() Input
- func (i Input) ToGrid() Grid[byte]
- func (i Input) ToGridS() Grid[String]
- func (i Input) ToIntSlice() []int
- func (i Input) ToPoints() []Point
- func (i Input) ToRanges(inclusive bool) []Range
- func (i Input) ToStringSlice() []String
- type Point
- func (p Point) Add(o Point) Point
- func (p1 Point) Distance(p2 Point) float64
- func (p Point) MoveEast() Point
- func (p Point) MoveNorth() Point
- func (p Point) MoveSouth() Point
- func (p Point) MoveWest() Point
- func (p Point) MultI(i int) Point
- func (p Point) RotateLeftZ() Point
- func (p Point) RotateRightZ() Point
- type Range
- type Runner
- type Set
- type Shape
- type Solver
- type String
- func (s String) At(i int) byte
- func (s String) Atoi() int
- func (s String) From(i int) String
- func (s String) Split() []String
- func (s String) SplitAtoi() []int
- func (s String) SplitOn(d string) []String
- func (s String) SplitOnAtoi(d string) []int
- func (s String) SplitOnS(d string) []string
- func (s String) SplitS() []string
- func (s String) ToIntSlice() []int
Constants ¶
const URL = "https://adventofcode.com"
Variables ¶
var SPACE_REGEX = regexp.MustCompile(`\s+`)
Functions ¶
func AllCombinations ¶ added in v1.14.0
Allcombinations returns an iterator over all combinations of elements in s.
func Atoi ¶ added in v0.1.3
Atoi is exactly like strconv.Atoi but does not return an error.
Instead it panics if anything goes wrong.
func Combinations ¶ added in v1.14.0
Combinations returns an iterator over all two sized combinations of elements in s.
func FirstMaxIndex ¶ added in v1.6.0
FirstMaxIndex returns the index of the first max value found, and the value.
func FirstMinIndex ¶ added in v1.6.0
FirstMaxIndex returns the index of the first min value found, and the value.
Types ¶
type Counter ¶ added in v0.4.0
type Counter struct {
// contains filtered or unexported fields
}
func NewCounter ¶ added in v0.4.0
func (Counter) GetKeys ¶ added in v0.4.0
func (c Counter) GetKeys() []CounterKey
type CounterKey ¶ added in v0.4.0
type DefaultCache ¶
type DefaultCache struct{}
func NewDefaultCache ¶
func NewDefaultCache() DefaultCache
func (DefaultCache) StoreInput ¶ added in v0.1.3
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
func NewDefaultClient ¶
func NewDefaultClient(session string) (DefaultClient, error)
func (DefaultClient) SendSolution ¶
type Grid ¶ added in v1.10.0
type Grid[E any] struct { // contains filtered or unexported fields }
Grid represent a grid.
It expects to be manipulated using Point objects to address positions in the grid.
func NewGridFromPoints ¶ added in v1.14.0
func (Grid[E]) Around ¶ added in v1.10.0
Around return an iterator over all the 8 points around a position.
If the position is on an edge of the grid, fewer than 8 points can be returned.
func (Grid[E]) IterAllColumn ¶ added in v1.11.0
func (Grid[E]) IterAllLine ¶ added in v1.12.0
func (Grid[E]) IterColumn ¶ added in v1.11.0
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
func NewInput ¶
NewInput return a new Input object.
By default the input is configured in multiline mode, without any delimiter, which is equivalent to using a "\n" delimiter.
func (Input) Delimiter ¶ added in v0.1.3
Delimiter sets the delimiter used by methods to split the input.
If the delimiter set is different than "" it overwrite the multiline configuration.
It returns the same input, so methods can be chained.
func (Input) SingleLine ¶ added in v0.1.3
SingleLine set the multiline mode to false.
In multiline mode, the input is split on "\n". In singleline, the input is split on each char.
If a delimiter is set, the multiline mode is ignored.
func (Input) ToGrid ¶ added in v1.9.0
ToGrid parses the input as a grid.
x is the axe from top to bottom, y is the axis from left to right. (0, 0) is the top left point.
func (Input) ToIntSlice ¶
ToIntSlice parse the input as a slice of int.
If a delimiter is set, it is used to split the input. Else in multiline mode the input is split on each line. Else the input is plit on each char.
If any part cannot be parsed as an int, it panics.
func (Input) ToPoints ¶ added in v1.14.0
ToPoints parses the input as a list of points, one by line.
The coordinates must be separated by commas.
func (Input) ToStringSlice ¶
ToStringSlice parse the input as a slice of String.
If a delimiter is set, it is used to split the input. Else in multiline mode the input is split on each line. Else the input is plit on each char.
type Point ¶ added in v0.1.3
func NewPointXY ¶ added in v1.13.0
func (Point) MoveNorth ¶ added in v1.4.0
MoveNorth return a new point one step to the north.
It supposes a grid where X goes from north to south, and Y from east to west.
func (Point) RotateLeftZ ¶ added in v0.1.3
func (Point) RotateRightZ ¶ added in v0.1.3
type Range ¶ added in v1.10.0
func CombineRanges ¶ added in v1.10.0
CombineRanges takes a list of ranges and return an equivalent list of non overlapping ranges.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func NewDefaultRunner ¶
Return a new Runner object with default cache and client.
This is the main constructor you should use.
func NewRunner ¶
Return a new Runner.
Unless you want to inject specific implementation for the cache and the client you should use NewDefaultRunner.
func (Runner) Benchmark ¶ added in v1.7.0
func (r Runner) Benchmark()
Benchmark runs a benchmark over all implemented solutions, and print the result.
type Set ¶ added in v1.14.0
type Set[E comparable] map[E]struct{}
func NewSet ¶ added in v1.14.0
func NewSet[E comparable](elems ...E) Set[E]
func NewSetFromIter ¶ added in v1.14.0
func NewSetFromIter[E comparable](elems iter.Seq[E]) Set[E]
type Shape ¶ added in v1.14.0
type Shape struct {
// contains filtered or unexported fields
}
type Solver ¶
type Solver interface {
Day1p1(Input) string
Day1p2(Input) string
Day2p1(Input) string
Day2p2(Input) string
Day3p1(Input) string
Day3p2(Input) string
Day4p1(Input) string
Day4p2(Input) string
Day5p1(Input) string
Day5p2(Input) string
Day6p1(Input) string
Day6p2(Input) string
Day7p1(Input) string
Day7p2(Input) string
Day8p1(Input) string
Day8p2(Input) string
Day9p1(Input) string
Day9p2(Input) string
Day10p1(Input) string
Day10p2(Input) string
Day11p1(Input) string
Day11p2(Input) string
Day12p1(Input) string
Day12p2(Input) string
Day13p1(Input) string
Day13p2(Input) string
Day14p1(Input) string
Day14p2(Input) string
Day15p1(Input) string
Day15p2(Input) string
Day16p1(Input) string
Day16p2(Input) string
Day17p1(Input) string
Day17p2(Input) string
Day18p1(Input) string
Day18p2(Input) string
Day19p1(Input) string
Day19p2(Input) string
Day20p1(Input) string
Day20p2(Input) string
Day21p1(Input) string
Day21p2(Input) string
Day22p1(Input) string
Day22p2(Input) string
Day23p1(Input) string
Day23p2(Input) string
Day24p1(Input) string
Day24p2(Input) string
Day25p1(Input) string
Day25p2(Input) string
}
An object implementing the solutions for all days.
A day method receives an Input object, and must return a string. If a day method returns an empty string, it will consider the solution is not implemented yet and it will not send it.
type String ¶ added in v0.2.0
type String string
func (String) From ¶ added in v0.2.0
From return the String from the given char position to the end.
func (String) SplitAtoi ¶ added in v0.2.0
SplitAtoi splits the String on spaces and convert the results to integers.
func (String) SplitOnAtoi ¶ added in v1.5.0
SplitOn splits the String using a given delimiter and convert the results to integers.
func (String) SplitOnS ¶ added in v1.2.0
SplitOn splits the String using a given delimiter and convert the results to string.
func (String) ToIntSlice ¶ added in v1.6.0
ToIntSlice convert the String to a slice of int.
It considers each char as an element of the result slice.