aoc

package
v0.0.0-...-61cdf16 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T Numbers](v T) T

func GCD

func GCD(nums ...int) int

func LCM

func LCM(nums ...int) int

func Mod

func Mod(a, b int) int

func Must

func Must(err error)

func ReadAllInput

func ReadAllInput() []string

func ReadAllInputFromFile

func ReadAllInputFromFile(name string) []string

func Sign

func Sign[T Numbers](v T) int

func StrToInt

func StrToInt(str string) int

func StrToInts

func StrToInts(str string) []int

Types

type Fraction

type Fraction struct {
	Numerator   int
	Denominator int
}

func NewFraction

func NewFraction(numerator, denominator int) Fraction

func (Fraction) Add

func (f Fraction) Add(s int) Fraction

func (Fraction) Div

func (f Fraction) Div(f2 Fraction) Fraction

func (Fraction) Equals

func (f1 Fraction) Equals(f2 Fraction) bool

func (Fraction) Float

func (f Fraction) Float() float64

func (Fraction) Mul

func (f Fraction) Mul(s int) Fraction

func (Fraction) Simplify

func (f Fraction) Simplify() Fraction

func (Fraction) String

func (f Fraction) String() string

func (Fraction) Sub

func (f Fraction) Sub(s int) Fraction

type Numbers

type Numbers interface {
	int | float64
}

type Vector2

type Vector2[T Numbers] struct {
	X T
	Y T
}

func NewVector2

func NewVector2[T Numbers](x, y T) Vector2[T]

func (Vector2[T]) Add

func (v Vector2[T]) Add(av Vector2[T]) Vector2[T]

func (Vector2[T]) ManhattanDst

func (v Vector2[T]) ManhattanDst(v2 Vector2[T]) T

func (Vector2[T]) Mul

func (v Vector2[T]) Mul(scalar T) Vector2[T]

func (Vector2[T]) Norm

func (v Vector2[T]) Norm() Vector2[T]

func (Vector2[T]) RotateLeft

func (v Vector2[T]) RotateLeft() Vector2[T]

RotateLeft rotates the vector to the left (left-handed system)

func (Vector2[T]) RotateRight

func (v Vector2[T]) RotateRight() Vector2[T]

RotateRight rotates the vector to the right (left-handed system)

func (Vector2[T]) String

func (v Vector2[T]) String() string

func (Vector2[T]) Sub

func (v Vector2[T]) Sub(av Vector2[T]) Vector2[T]

type Vector3

type Vector3 struct {
	X int
	Y int
	Z int
}

func NewVector3

func NewVector3(x, y, z int) Vector3

Jump to

Keyboard shortcuts

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