helpers

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

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

Go to latest
Published: Dec 8, 2022 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(x int64) int64

func Atoi

func Atoi(str string) int

func GCD

func GCD(x, y int64) int64

func IncDecCount

func IncDecCount(input []int) (incCount, decCount int)

func InputToLines

func InputToLines(file string) (lines []string)

func IntSlidingWindowSum

func IntSlidingWindowSum(input []int, window int) (sums []int)

func LCM

func LCM(a, b int64, integers ...int64) int64

func LinesToFloats

func LinesToFloats(file *os.File) (floats []float64, err error)

func LinesToInts

func LinesToInts(file *os.File) (ints []int, err error)

func LinesToStrings

func LinesToStrings(file *os.File) (strings []string)

func Max

func Max(m map[string]int) (ind string)

Max finds the max in a string - int map

func Min

func Min(m map[string]int) (ind string)

Min finds the min in a string - int map

func MinInt

func MinInt(m []int) (min int)

Min finds the min in a string - int map

func OpenFile

func OpenFile(f string) (file *os.File)

OpenFile well, it opens a file based on a path :p

func PrintImage

func PrintImage(image [][]string)

func RenderGrid

func RenderGrid(grid map[Point]int64) [][]string

func ReverseSlice

func ReverseSlice[S ~[]E, E any](s S)

func RunProgram

func RunProgram(prog []string, output chan<- int, halt, loop chan<- bool)

func RunRobot

func RunRobot(grid map[Point]int64, start Point, input <-chan int64, output chan<- int64)

func SortSlice

func SortSlice[T constraints.Ordered](s []T)

func StreamLines

func StreamLines(file string, output chan<- string)

func StreamRunes

func StreamRunes(file string, output chan<- rune)

func StreamStrings

func StreamStrings(file string, output chan<- string)

func Sum

func Sum[T Number](slice []T) (sum T)

func SumOfFloat64Array

func SumOfFloat64Array(test []float64) (result float64)

SumOfFloat64Array sums all float64 in the array

func SumOfIntArray

func SumOfIntArray(test []int) (result int)

SumOfIntArray sums all int in the array

func ToggleInstruction

func ToggleInstruction(prog []string, ind int) []string

Types

type Graph

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

func NewGraph

func NewGraph() *Graph

func (*Graph) AddChildToParent

func (g *Graph) AddChildToParent(childKey, parentKey int)

func (*Graph) GetPath

func (g *Graph) GetPath(start, end int) []int

func (*Graph) GetPaths

func (g *Graph) GetPaths(key int) int

type Node

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

type Number

type Number interface {
	constraints.Float | constraints.Integer
}

Type constraint for general numbers

type Point

type Point struct {
	X, Y int64
}

func NewPoint

func NewPoint(x, y int64) *Point

func ParsePoint

func ParsePoint(str string) *Point

Parse a point from a x,y notation

func (*Point) Angle

func (p *Point) Angle(t Point) (angle float64)

func (*Point) ManhattanDist

func (p *Point) ManhattanDist(t Point) int64

func (*Point) Move

func (p *Point) Move(n [2]int64)

func (*Point) MoveDir

func (p *Point) MoveDir(dir rune)

func (*Point) MoveDirN

func (p *Point) MoveDirN(dir rune, steps int64)

func (*Point) MoveRelative

func (p *Point) MoveRelative(n *Point)

func (*Point) MoveRelativeN

func (p *Point) MoveRelativeN(n *Point, times int64)

func (*Point) Rotate90

func (p *Point) Rotate90(cc bool)

type Vertex

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

Jump to

Keyboard shortcuts

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