tools

package
v0.0.0-...-0ed62f3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(num int) int

Abs returns the absoulute value

func ClearOutput

func ClearOutput()

ClearOutput clears the screen

func CreateIntcodeData

func CreateIntcodeData(line string) ([]int, error)

CreateIntcodeData get an []int for intcode from a string

func Gcd

func Gcd(num, num2 int) int

Gcd finds the greatest common factor

func GridMinMax

func GridMinMax(area map[int]map[int]int) (int, int, int, int)

GridMinMax returns minX, maxX, minY, maxY

func GridSet

func GridSet(area map[int]map[int]int, pos Pos2D, val int)

GridSet sets a spot on the grid

func Lcm

func Lcm(num, num2 int) int

Lcm returns the least commone multiple

func ReadFile

func ReadFile(filename string) (string, error)

ReadFile Reads a file to string

func ReadFileLines

func ReadFileLines(filename string) ([]string, error)

ReadFileLines reads the file lines to an array

func ReadFileLinesRemoveLast

func ReadFileLinesRemoveLast(filename string) ([]string, error)

ReadFileLinesRemoveLast reads the file lines to an array and removes the last line if it's blank

func TrimFirstChar

func TrimFirstChar(s string) (string, string)

TrimFirstChar trims the first char from the string

Types

type IntcodeProgram

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

IntcodeProgram stores the intcode progrm

func NewProgram

func NewProgram(line string) (*IntcodeProgram, error)

NewProgram create a new intcode program

func NewProgramFromData

func NewProgramFromData(data []int) *IntcodeProgram

NewProgramFromData create a new intcode program from []int

func (*IntcodeProgram) AddInput

func (p *IntcodeProgram) AddInput(data int)

AddInput adds to the input queue

func (*IntcodeProgram) GetData

func (p *IntcodeProgram) GetData(index int) int

GetData Get data at the index

func (*IntcodeProgram) GetStopped

func (p *IntcodeProgram) GetStopped() bool

GetStopped get if the program is really done

func (*IntcodeProgram) RemoveOutput

func (p *IntcodeProgram) RemoveOutput() (int, error)

RemoveOutput removes and returns data from the output queue

func (*IntcodeProgram) Run

func (p *IntcodeProgram) Run() error

Run runs the program until it needs more input or finishes

func (*IntcodeProgram) SetData

func (p *IntcodeProgram) SetData(index, data int)

SetData Set data at the index

type Pos2D

type Pos2D struct {
	X int
	Y int
}

Pos2D a 2D pos

func (*Pos2D) Add

func (pos *Pos2D) Add(pos2 Pos2D) Pos2D

Add adds two points

func (*Pos2D) MDist

func (pos *Pos2D) MDist(pos2 *Pos2D) int

MDist calculates the manhattan distance between two points

type Pos3D

type Pos3D struct {
	X int
	Y int
	Z int
}

Pos3D a 4D pos

func (*Pos3D) Add

func (pos *Pos3D) Add(pos2 Pos3D) Pos3D

Add adds two points

func (*Pos3D) MDist

func (pos *Pos3D) MDist(pos2 *Pos3D) int

MDist calculates the manhattan distance between two points

type Pos4D

type Pos4D struct {
	W int
	X int
	Y int
	Z int
}

Pos4D a 4D pos

func (*Pos4D) Add

func (pos *Pos4D) Add(pos2 Pos4D) Pos4D

Add adds two points

Jump to

Keyboard shortcuts

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