aocutils

package
v0.0.0-...-7a3a950 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: MIT Imports: 4 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsFloat

func AbsFloat(x float64) float64

AbsFloat returns the absolute value of a float.

func AbsInt

func AbsInt(x int) int

SignInt returns the absolute value of an int.

func Atof

func Atof(s string) float64

Atof gets a float from a string.

func Atoi

func Atoi(s string) int

Atoi gets an int from a string.

func Check

func Check(err error)

Check panics if the given error is not nil.

func MaxFloat

func MaxFloat(x, y float64) float64

MinFloat returns the largest float between the given arguments.

func MaxInt

func MaxInt(x, y int) int

MaxInt returns the largest int between the given arguments.

func MinFloat

func MinFloat(x, y float64) float64

MinFloat returns the smallest float between the given arguments.

func MinInt

func MinInt(x, y int) int

MinInt returns the smallest int between the given arguments.

func SignFloat

func SignFloat(x float64) float64

SignFloat returns the sign of a float.

func SignInt

func SignInt(x int) int

SignInt returns the sign of an int.

Types

type Grid

type Grid struct {
	Width  int
	Height int

	Formats map[rune]func(string, ...interface{}) string
	// contains filtered or unexported fields
}

func NewGrid

func NewGrid(s string) Grid

NewGrid makes a new grid from a multiline grid string. e.g.: /------\ | o x| \------/

func (Grid) Cell

func (g Grid) Cell(pos Vector2D) rune

Cell returns a cell with the given coordinates.

func (Grid) CountChars

func (g Grid) CountChars(r rune) int

CountChars counts the amount of cells that contain a given rune in the grid.

func (Grid) Display

func (g Grid) Display()

Display prints the grid.

func (Grid) PrintCell

func (g Grid) PrintCell(x, y int)

PrintCell prints a cell using custom formatting if any is specified.

func (Grid) Set

func (g Grid) Set(pos Vector2D, r rune)

type Vector2D

type Vector2D struct {
	// contains filtered or unexported fields
}

Vector2D represents a 2D set of ints.

func NewVector2D

func NewVector2D(x, y int) Vector2D

NewVector2D creates a new vector.

func (Vector2D) Add

func (v Vector2D) Add(other Vector2D) Vector2D

Add adds another vector to the vector.

func (Vector2D) DistanceSquared

func (v Vector2D) DistanceSquared(o Vector2D) int

DistanceSquared calculates the difference between the squared length of this vector and another.

func (Vector2D) IsUnset

func (v Vector2D) IsUnset() bool

IsUnset returns whether the vector is set.

func (Vector2D) Length

func (v Vector2D) Length() int

Length calculates the length of the vector.

func (Vector2D) LengthSquared

func (v Vector2D) LengthSquared() int

LengthSquared calculates the square of the length of the vector.

func (Vector2D) ManhattanDistance

func (v Vector2D) ManhattanDistance(o Vector2D) int

ManhattanDistance calculates the Manhattan distance between the vector and another vector.

func (Vector2D) ManhattanLength

func (v Vector2D) ManhattanLength() int

ManhattanLength calculates the Manhattan length of the vector.

func (Vector2D) Mul

func (v Vector2D) Mul(factor int) Vector2D

Mul multiplies the vector with the values of another vector.

func (Vector2D) Sub

func (v Vector2D) Sub(other Vector2D) Vector2D

Sub subtracts another vector to the vector.

func (Vector2D) X

func (v Vector2D) X() int

X returns the x value of the vector.

func (Vector2D) Y

func (v Vector2D) Y() int

Y returns the y value of the vector.

type Vector3D

type Vector3D struct {
	// contains filtered or unexported fields
}

Vector2D represents a 2D set of ints.

func (Vector3D) Add

func (v Vector3D) Add(other Vector3D) Vector3D

Add adds another vector to the vector.

func (Vector3D) DistanceSquared

func (v Vector3D) DistanceSquared(o Vector3D) int

DistanceSquared calculates the difference between the squared length of this vector and another.

func (Vector3D) Length

func (v Vector3D) Length() int

Length calculates the length of the vector.

func (Vector3D) LengthSquared

func (v Vector3D) LengthSquared() int

LengthSquared calculates the square of the length of the vector.

func (Vector3D) ManhattanDistance

func (v Vector3D) ManhattanDistance(o Vector3D) int

ManhattanDistance calculates the Manhattan distance between the vector and another vector.

func (Vector3D) ManhattanLength

func (v Vector3D) ManhattanLength() int

ManhattanLength calculates the Manhattan length of the vector.

func (Vector3D) Mul

func (v Vector3D) Mul(factor int) Vector3D

Mul multiplies the vector with the values of another vector.

func (Vector3D) Sub

func (v Vector3D) Sub(other Vector3D) Vector3D

Sub subtracts another vector to the vector.

Jump to

Keyboard shortcuts

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