aoc2022

package module
v0.0.0-...-2fdb5a5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 10 Imported by: 0

README

adventofcode2022

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T constraints.Integer | constraints.Float](x T) T

Abs returns the absolute (non negative) value of the input

func Count

func Count[T any](in []T, countFn func(T) bool) int

Count returns an int of the number if values in the input slice that return true when evaluated by countFn

func GCD

func GCD[T constraints.Signed | constraints.Unsigned](a, b T) T

greatest common divisor (GCD) via Euclidean algorithm

func InputFromWebsite

func InputFromWebsite(day string) string

InputFromWebsite reads the AOC_SESSION env variable to form the session cookie and then reads the input for the appropriate day. NB says are not zero prefixed so day one is just "1"

TODO oauth login via github etc. so I don't have to steal the session cookie from my browser

func Int

func Int(value string) int64

func LCM

func LCM[T constraints.Signed | constraints.Unsigned](integers ...T) T

find Least Common Multiple (LCM) via GCD

func Max

func Max[T constraints.Ordered](in ...T) T

Max returns the maximum value in the input slice

func Min

func Min[T constraints.Ordered](in ...T) T

Min returns the minimum value in the input slice

func Slice

func Slice[T any](data string, separator string, convert func(string) T) []T

Slice creates a generic slice from the split input data

func UInt

func UInt(value string) uint64

Types

type Coord

type Coord struct {
	X, Y int
}

func (*Coord) Diff

func (c *Coord) Diff(other Coord) Coord

func (*Coord) Distance

func (c *Coord) Distance(b Coord) int

func (*Coord) Move

func (c *Coord) Move(direction Coord) Coord

type RuneStack

type RuneStack []rune

func NewRuneStack

func NewRuneStack() RuneStack

func (*RuneStack) IsEmpty

func (s *RuneStack) IsEmpty() bool

func (*RuneStack) Pop

func (s *RuneStack) Pop() rune

func (*RuneStack) Push

func (s *RuneStack) Push(runes ...rune)

func (*RuneStack) String

func (s *RuneStack) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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