aoc

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 10 Imported by: 28

README

Advent of Code: Go library stuff

These are basic tools and functions for the actual Advent Of Code solutions.

Disclaimer

These are my personal solutions of the Advent Of Code (AOC). The code is not indented to be perfect in any kind of area.

If you think, there is a piece of improvement: Go to the code, fill a PR and we are all happy. Share the knowledge.

Everything is free for all.

Licensed under MIT. Copyright Jan Philipp.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AocYear = 2020
View Source
var Registry = newRegistry()

Functions

func AbsInt

func AbsInt(a int) int

func BinarySearch

func BinarySearch(min int, max int, worker func(i int) bool, debug bool) int

func GreatestCommonDivisor

func GreatestCommonDivisor(a int, n ...int) int

GGT

func LeastCommonMultiple

func LeastCommonMultiple(a int, n ...int) int

KGV

func MaxInt

func MaxInt(a, b int) int

func MaxIntArrayValue

func MaxIntArrayValue(arr []int) int

func MinInt

func MinInt(a, b int) int

func ParseInt

func ParseInt(s string) int

func ParseStringToIntArray

func ParseStringToIntArray(lines []string) []int

func Permutations

func Permutations(arr []int) [][]int

func PrintDayHeader

func PrintDayHeader(day int, title string)

noinspection GoUnhandledErrorResult

func PrintError

func PrintError(err error)

noinspection GoUnhandledErrorResult

func PrintSolution

func PrintSolution(result interface{})

noinspection GoUnhandledErrorResult

func PrintStepHeader

func PrintStepHeader(step int)

noinspection GoUnhandledErrorResult

func ReadFileAsIntArray

func ReadFileAsIntArray(file string) []int

func ReadFileToArray

func ReadFileToArray(path string) ([]string, error)

* Read a file and returning the lines as array (without newlines)

func ReadFileToString

func ReadFileToString(path string) (*string, error)

* Read a file and returns its content as one string

Types

type CalleeType

type CalleeType = func([]string) error

type Direction

type Direction string
const EAST Direction = "east"
const NORTH Direction = "north"
const SOUTH Direction = "south"
const WEST Direction = "west"

func NewDirection

func NewDirection(str string) Direction

func (Direction) Left

func (d Direction) Left() Direction

func (Direction) Return

func (d Direction) Return() Direction

func (Direction) Right

func (d Direction) Right() Direction

func (Direction) ToString

func (d Direction) ToString() string

type PQItem

type PQItem struct {
	Value    interface{}
	Priority int
	// contains filtered or unexported fields
}

type PriorityQueue

type PriorityQueue []*PQItem

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type RegistryType

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

func (*RegistryType) Invoke

func (r *RegistryType) Invoke(day int, args []string) error

func (*RegistryType) Register

func (r *RegistryType) Register(day int, callee CalleeType)

Jump to

Keyboard shortcuts

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