Documentation
¶
Index ¶
- Constants
- Variables
- func Abs(a int) int
- func Atoi(s string) int
- func CRT(cycles []Cycle) int
- func Check(err error)
- func Cmp(a, b int) int
- func ContainsInt(x int, entries []int) bool
- func ContainsString(x string, entries []string) bool
- func CountInts(entries []int) map[int]int
- func CountStrings(entries []string) map[string]int
- func Cut(s string, separator string) (left, right string)
- func FirstAsciiNr(s string) int
- func GCD(a, b int) int
- func LCM(values []int) int
- func Max(numbers []int) int
- func Min(numbers []int) int
- func MinMax(a, b int) (int, int)
- func MinMaxInts(numbers []int) (int, int)
- func ReadLinesFromFile(path string) []string
- func ReadNumbersFromFile(path string) []int
- func ReadRawLinesFromFile(path string) []string
- func ReverseSlice[T any](s []T)
- func Sign(a int) int
- func Sort(a []int)
- func SplitToChars(line string) []string
- func SplitToInts(line string) []int
- func SplitToRunes(line string) []rune
- func SplitWithSpace(line string) []string
- func SplitWithTrim(line, splitPattern string) []string
- func Triangle(nr int) int
- func Trim(line string) string
- func TrimTrailingNewline(lines []string) []string
- type CharGrid
- type Command
- type Cycle
- type DigitGrid
- type Grid2D
- func (g *Grid2D[T]) At(row, col int) T
- func (g Grid2D[T]) AtBorder(row, col int) bool
- func (g *Grid2D[T]) Find(value T) (row, col int, ok bool)
- func (g Grid2D[T]) Get(row, col int) T
- func (g Grid2D[T]) InBounds(row, col int) bool
- func (g *Grid2D[T]) Set(val T, row, col int)
- func (g *Grid2D[T]) SetAll(value T)
- type Grid3D
- type Pos2D
- type RuneGrid
- type Set
- func (s Set[K]) Add(elem K)
- func (s Set[K]) Clone() Set[K]
- func (s Set[K]) Contains(elem K) bool
- func (s Set[K]) Extend(other Set[K])
- func (s Set[K]) GetOne() K
- func (s Set[K]) Intersect(other Set[K])
- func (s Set[K]) Remove(elem K)
- func (s Set[K]) Size() int
- func (s Set[K]) Subtract(other Set[K])
- func (s Set[K]) Values() []K
- type Stack
Constants ¶
const (
MaxInt = 9223372036854775807
)
Variables ¶
var NeighborsAll [][3]int
var NeighborsStraight = [][3]int{{-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}}
Functions ¶
func CRT ¶
CRT is a function that takes a slice of cycles and returns the smallest number that satisfies all the cycles according to the Chinese Remainder Theorem.
func ContainsInt ¶
func ContainsString ¶
func CountStrings ¶
func FirstAsciiNr ¶
FirstAsciiNr return ascii number of first character in string. Panics if value > 127.
func MinMaxInts ¶
func ReadLinesFromFile ¶
ReadLinesFromFile reads lines from a file.
func ReadNumbersFromFile ¶
ReadNumbersFromFile reads one integer from each line in file.
func ReadRawLinesFromFile ¶
ReadRawLinesFromFile reads lines from a file.
func ReverseSlice ¶
func ReverseSlice[T any](s []T)
func SplitToInts ¶
SplitToInts finds all ints in line (including sign).
func SplitWithSpace ¶
SplitWithSpace splits a line with space as separator.
func SplitWithTrim ¶
func TrimTrailingNewline ¶
TrimTrailingNewline removes trailing newline
Types ¶
type Command ¶
func ParseCommand ¶
ParseCommand parses a "verb value" from a line.
type Cycle ¶
type Cycle struct {
Offset, Period int
}
Cycle is a struct that represents a cycle with an offset and a period.
type Grid2D ¶
type Grid2D[T comparable] struct { Grid [][]T Width int Height int }
func CreateGrid2D ¶
func CreateGrid2D[T comparable](width, height int) Grid2D[T]
type RuneGrid ¶
func CreateRuneGridFromLines ¶
type Set ¶
type Set[K comparable] map[K]struct{}
Set - mathematical set with operations Empty struct requires zero bytes so is more efficient than bool
func (Set[K]) Remove ¶
func (s Set[K]) Remove(elem K)
Remove - remove elem from set (does not need to be in set)