advent2021

package module
v0.0.0-...-acf6961 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2021 License: MIT Imports: 9 Imported by: 0

README

advent2021

Advent of Code 2021 solutions.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingInput = errors.New("advent2021: missing input")
	ErrNoSolution   = errors.New("advent2021: no solution")
)
View Source
var (
	North = XY{0, 1}
	East  = XY{1, 0}
	South = XY{0, -1}
	West  = XY{-1, 0}

	NorthEast = XY{1, 1}
	SouthEast = XY{1, -1}
	SouthWest = XY{-1, -1}
	NorthWest = XY{-1, 1}

	Dirs         = [4]XY{North, East, South, West}
	DiagonalDirs = [4]XY{NorthEast, SouthEast, SouthWest, NorthWest}
)

Functions

func Abs

func Abs(x int) int

func IsLower

func IsLower(s string) bool

func Max

func Max(x, y int) int

func MaxInts

func MaxInts(ns []int) int

func Min

func Min(x, y int) int

func MinInts

func MinInts(ns []int) int

func Product

func Product(ns []int) int

func ReadIntLines

func ReadIntLines(name string) ([][]int, error)

func ReadIntLinesReader

func ReadIntLinesReader(r io.Reader) ([][]int, error)

func ReadInts

func ReadInts(name string) ([]int, error)

func ReadStringGroups

func ReadStringGroups(name string) ([][]string, error)

ReadStringGroups reads a file of string data formed of groups of lines, where groups are separated by an empty line.

func ReadStrings

func ReadStrings(name string) ([]string, error)

func Sign

func Sign(x int) int

func Sum

func Sum(ns []int) int

Types

type XY

type XY struct {
	X, Y int
}

func (XY) Add

func (p1 XY) Add(p2 XY) XY

func (XY) InRange

func (p XY) InRange(x [2]int, y [2]int) bool

func (XY) Multiply

func (p XY) Multiply(n int) XY

func (XY) Neighbours

func (p XY) Neighbours(includeDiagonals bool) []XY

func (XY) Sign

func (p XY) Sign() XY

func (XY) Subtract

func (p1 XY) Subtract(p2 XY) XY

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL