day20

package
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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTiles

func ParseTiles(groups [][]string) (map[int]Tile, error)

func Part1

func Part1(p *Picture) int

func Part2

func Part2(p *Picture) (int, error)

Types

type BFSNode

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

func (*BFSNode) IsGoal

func (b *BFSNode) IsGoal() bool

func (*BFSNode) Key

func (b *BFSNode) Key() interface{}

We don't need to worry about hitting the same state twice. Stop the BFS implementation from worrying about this with this lovely little bodge.

func (*BFSNode) Neighbours

func (b *BFSNode) Neighbours() ([]bfs.Node, error)

type Noncer

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

func NewNoncer

func NewNoncer() *Noncer

func (*Noncer) Nonce

func (n *Noncer) Nonce() int

type Picture

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

func BuildPicture

func BuildPicture(tiles map[int]Tile) (*Picture, error)

func NewPicture

func NewPicture(size, tileSize int) Picture

func (Picture) Clone

func (p Picture) Clone() Picture

func (Picture) Fits

func (p Picture) Fits(t Tile, pos advent2020.XY) bool

func (Picture) ImageString

func (p Picture) ImageString(includeBorders bool) string

func (Picture) InBounds

func (p Picture) InBounds(pos advent2020.XY) bool

func (Picture) NextEmptySquare

func (p Picture) NextEmptySquare() *advent2020.XY

We fill in the picture from left to right, top to bottom. Moving in this direction, NextEmptySquare returns the position of the next square to be filled, or nil if it is already full.

func (Picture) Place

func (p Picture) Place(t Tile, tileID int, pos advent2020.XY) Picture

func (Picture) String

func (p Picture) String() string

func (Picture) TileAt

func (p Picture) TileAt(pos advent2020.XY) Tile

type Tile

type Tile [][]byte

func (Tile) BottomSideMatchesTopOf

func (t Tile) BottomSideMatchesTopOf(neighbour Tile) bool

func (Tile) Flip

func (t Tile) Flip() Tile

func (Tile) HaveMonsterAt

func (t Tile) HaveMonsterAt(y, x int) bool

func (Tile) Permutations

func (t Tile) Permutations() []Tile

func (Tile) ReplaceMonsterAt

func (t Tile) ReplaceMonsterAt(y, x int)

func (Tile) ReplaceSeaMonsters

func (t Tile) ReplaceSeaMonsters() bool

func (Tile) RightSideMatchesLeftOf

func (t Tile) RightSideMatchesLeftOf(neighbour Tile) bool

func (Tile) RotateLeft

func (t Tile) RotateLeft() Tile

func (Tile) RotatePermutations

func (t Tile) RotatePermutations() []Tile

Jump to

Keyboard shortcuts

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