aoc

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 12 Imported by: 0

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 MinIntArrayValue added in v1.2.0

func MinIntArrayValue(arr []int) int

func ParseInt

func ParseInt(s string) int

func ParseInts added in v1.0.3

func ParseInts(str string, delim 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, error)

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 LinkElement added in v1.3.0

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

func (*LinkElement) Next added in v1.3.0

func (e *LinkElement) Next() *LinkElement

func (*LinkElement) Prev added in v1.3.0

func (e *LinkElement) Prev() *LinkElement

func (*LinkElement) Value added in v1.3.0

func (e *LinkElement) Value() interface{}

type LinkedList added in v1.3.0

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

func NewLinkedList added in v1.3.0

func NewLinkedList(ring bool) *LinkedList

func (*LinkedList) Add added in v1.3.0

func (l *LinkedList) Add(value interface{}) *LinkElement

func (*LinkedList) AddAfter added in v1.3.0

func (l *LinkedList) AddAfter(after *LinkElement, value interface{}) *LinkElement

func (*LinkedList) Back added in v1.3.0

func (l *LinkedList) Back() *LinkElement

func (*LinkedList) Each added in v1.3.0

func (l *LinkedList) Each(iter func(e *LinkElement))

func (*LinkedList) EachStartAt added in v1.3.0

func (l *LinkedList) EachStartAt(start *LinkElement, iter func(e *LinkElement))

func (*LinkedList) Filter added in v1.3.0

func (l *LinkedList) Filter(filter func(e *LinkElement) bool) *LinkElement

func (*LinkedList) Front added in v1.3.0

func (l *LinkedList) Front() *LinkElement

func (*LinkedList) Len added in v1.3.0

func (l *LinkedList) Len() int

func (*LinkedList) Remove added in v1.3.0

func (l *LinkedList) Remove(e *LinkElement)

func (*LinkedList) ToString added in v1.3.0

func (l *LinkedList) ToString(transform func(e *LinkElement) string) 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 Queue added in v1.2.0

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

func NewQueue added in v1.2.0

func NewQueue() *Queue

func (*Queue) Add added in v1.2.0

func (q *Queue) Add(v interface{})

func (*Queue) Clone added in v1.2.1

func (q *Queue) Clone() *Queue

func (*Queue) Head added in v1.2.0

func (q *Queue) Head() interface{}

func (*Queue) Init added in v1.2.0

func (q *Queue) Init()

func (*Queue) IsEmpty added in v1.2.0

func (q *Queue) IsEmpty() bool

func (*Queue) Len added in v1.2.0

func (q *Queue) Len() int

func (*Queue) LookHead added in v1.2.0

func (q *Queue) LookHead() interface{}

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)

type Stack added in v1.2.0

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

func NewStack added in v1.2.0

func NewStack() *Stack

func (*Stack) Add added in v1.2.0

func (s *Stack) Add(v interface{})

func (*Stack) Clone added in v1.2.1

func (s *Stack) Clone() *Stack

func (*Stack) Head added in v1.2.0

func (s *Stack) Head() interface{}

func (*Stack) Init added in v1.2.0

func (s *Stack) Init()

func (*Stack) IsEmpty added in v1.2.0

func (s *Stack) IsEmpty() bool

func (*Stack) Len added in v1.2.0

func (s *Stack) Len() int

func (*Stack) LookHead added in v1.2.0

func (s *Stack) LookHead() interface{}

Jump to

Keyboard shortcuts

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