lib

package
v1.9.84 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: GPL-2.0, GPL-3.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Diagnals = []image.Point{
	image.Point{1, 1},
	image.Point{1, -1},
	image.Point{-1, -1},
	image.Point{-1, 1},
}
View Source
var Directions = []image.Point{
	image.Point{0, 1},
	image.Point{0, -1},
	image.Point{-1, 0},
	image.Point{1, 0},
}
View Source
var Inputs []string

All puzzle inputs stored as an array of UTF-8 strings.

View Source
var NumberRE = regexp.MustCompile(`[-+]?\d*\.?\d*`)

Functions

func Apply

func Apply(f func(int) int, c <-chan int) <-chan int

func CSVParser

func CSVParser(input string) []string

CSVParser ...

func ContextWithSignals

func ContextWithSignals(ctx context.Context) context.Context

func DashParser

func DashParser(input string) []string

DashParser ...

func Euclid added in v1.6.5

func Euclid(p, q image.Point) float64

func GetInput

func GetInput(year, day int, sessionCookie string) (r string, err error)

GetInput returns the puzzle input for the given day.

func InputFloats

func InputFloats(input string, parser func(string) []string) [][]float64

Returns the input as a two-dimensional array of float64.

func InputInts

func InputInts(input string, parser func(string) []string) [][]int

Returns the input as a two-dimensional array of int.

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

func Neighbors4 added in v1.6.8

func Neighbors4(p image.Point) (r []image.Point)

Returns the neighbors up, down, left, and right of P.

func Neighbors8 added in v1.9.23

func Neighbors8(p image.Point) (r []image.Point)

Returns the neighbors UDLR of P and the diagnals.

func NumberParser

func NumberParser(input string) []string

NumberParser ...

func ParseInput

func ParseInput(input string, parser func(string) []string) [][]string

Parses each line of the input with the given parser function.

func Reduce

func Reduce(f func(int, int) int, c <-chan int) (r int)

func Sign

func Sign(a int) int

func Taxi added in v1.6.5

func Taxi(p, q image.Point) float64

func TrimSpace

func TrimSpace(input []string) (r []string)

Trimmer ...

func UDLR added in v1.6.8

func UDLR(p, q image.Point) int

Returns 1, 2, 3, or 4 if q is the up, down, left, or right neighbor of P, or 0 otherwise.

Types

type Dim added in v1.6.5

type Dim int

func (Dim) Index added in v1.6.5

func (n Dim) Index(p image.Point) int

func (Dim) Point added in v1.6.5

func (n Dim) Point(i int) image.Point

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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