advent2020

package module
v0.0.0-...-38c8f7e Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: MIT Imports: 7 Imported by: 0

README

advent2020

Advent of Code 2020 solutions.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Compass = map[CompassDirection]XY{
	North: {0, 1},
	East:  {1, 0},
	South: {0, -1},
	West:  {-1, 0},
}
View Source
var Directions = []XY{
	{-1, -1},
	Compass[West],
	{-1, 1},
	Compass[South],
	Compass[North],
	{1, -1},
	Compass[East],
	{1, 1},
}
View Source
var ErrEmptySlice = errors.New("advent2020: slice is empty")
View Source
var ErrNoResult = errors.New("advent2020: no result found")
View Source
var HexCompass = map[HexDirection]XYZ{
	HexEast:      {1, -1, 0},
	HexSouthEast: {0, -1, 1},
	HexSouthWest: {-1, 0, 1},
	HexWest:      {-1, 1, 0},
	HexNorthWest: {0, 1, -1},
	HexNorthEast: {1, 0, -1},
}

https://www.redblobgames.com/grids/hexagons/#coordinates-cube

Functions

func Abs

func Abs(x int) int

func Max

func Max(x, y int) int

func MaxInts

func MaxInts(ns []int) (int, error)

func Min

func Min(x, y int) int

func MinInts

func MinInts(ns []int) (int, error)

func ReadDigits

func ReadDigits(in string) ([]int, error)

func ReadIntLines

func ReadIntLines(r io.Reader) ([][]int, error)

func ReadInts

func ReadInts(name string) ([]int, error)

func ReadStringGroups

func ReadStringGroups(name string) ([][]string, error)

ReadStringGroups reads a file of string data formed of groups of lines, where groups are separated by an empty line.

func ReadStrings

func ReadStrings(name string) ([]string, error)

Types

type CompassDirection

type CompassDirection int
const (
	North CompassDirection = iota
	East
	South
	West
)

func (CompassDirection) RotateAnticlockwise

func (d CompassDirection) RotateAnticlockwise(steps int) CompassDirection

func (CompassDirection) RotateClockwise

func (d CompassDirection) RotateClockwise(steps int) CompassDirection

type HexDirection

type HexDirection int
const (
	HexEast HexDirection = iota
	HexSouthEast
	HexSouthWest
	HexWest
	HexNorthWest
	HexNorthEast
)

type WXYZ

type WXYZ struct {
	W, X, Y, Z int
}

func (WXYZ) Add

func (p1 WXYZ) Add(p2 WXYZ) WXYZ

func (WXYZ) Adjacent

func (p WXYZ) Adjacent() []WXYZ

type XY

type XY struct {
	X, Y int
}

func (XY) Add

func (p1 XY) Add(p2 XY) XY

func (XY) Adjacent

func (p XY) Adjacent() []XY

func (XY) Manhattan

func (p XY) Manhattan() int

func (XY) Multiply

func (p XY) Multiply(n int) XY

func (XY) RotateAnticlockwise

func (p XY) RotateAnticlockwise(steps int) XY

func (XY) RotateClockwise

func (p XY) RotateClockwise(steps int) XY

type XYZ

type XYZ struct {
	X, Y, Z int
}

func (XYZ) Add

func (p1 XYZ) Add(p2 XYZ) XYZ

func (XYZ) AddHexCompass

func (p XYZ) AddHexCompass(d HexDirection) XYZ

func (XYZ) HexAdjacent

func (p XYZ) HexAdjacent() []XYZ

Jump to

Keyboard shortcuts

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