exercises

package
v0.0.0-...-e61498d Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Unlicense Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAPNG

func GenerateAPNG(frames []*image.RGBA, output string) error

Types

type Block

type Block struct {
	HeatLoss int
	Position Point
	City     *City
}

func (*Block) GetNeighbors

func (b *Block) GetNeighbors() []Pather

func (*Block) PathEstimatedCost

func (b *Block) PathEstimatedCost(to Pather) float64

func (*Block) PathNeighborCost

func (b *Block) PathNeighborCost(to Pather) float64

type BucketQueue

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

BucketQueue represents a bucket queue data structure

func NewBucketQueue

func NewBucketQueue() *BucketQueue

NewBucketQueue initializes a new BucketQueue with a given maxPriority

func (*BucketQueue) Dequeue

func (bq *BucketQueue) Dequeue() (any, bool)

Dequeue removes and returns the element with the highest priority (lowest number)

func (*BucketQueue) Enqueue

func (bq *BucketQueue) Enqueue(priority int, value any)

Enqueue adds a new element to the queue with a specified priority

func (*BucketQueue) IsEmpty

func (bq *BucketQueue) IsEmpty() bool

IsEmpty checks if the queue is empty

func (*BucketQueue) Pop

func (bq *BucketQueue) Pop() State

type City

type City struct {
	Blocks map[Point]*Block
	Width  int
	Height int
}

func LoadCity

func LoadCity(input string) (*City, error)

func (City) End

func (c City) End() *Block

func (*City) GenerateFrame

func (c *City) GenerateFrame(path []Pather, s string) (*image.RGBA, error)

func (*City) GenerateImage

func (c *City) GenerateImage(path []Pather, outfile string) error

func (*City) Path

func (c *City) Path(start, end Pather) ([]Pather, float64, bool)

func (City) Start

func (c City) Start() *Block

type Direction

type Direction rune
const (
	UpDir    Direction = 'u'
	DownDir  Direction = 'd'
	RightDir Direction = 'r'
	LeftDir  Direction = 'l'
)

type Exercise

type Exercise struct {
	common.BaseExercise
}

Exercise for Advent of Code 2023 day 17.

func (Exercise) One

func (e Exercise) One(input string) (any, error)

One returns the answer to the first part of the exercise.

func (Exercise) Two

func (e Exercise) Two(input string) (any, error)

Two returns the answer to the second part of the exercise.

type Pather

type Pather interface {
	GetNeighbors() []Pather
	PathNeighborCost(to Pather) float64
	PathEstimatedCost(to Pather) float64
}

type Point

type Point util.Point2D

func (Point) String

func (p Point) String() string

type State

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

Jump to

Keyboard shortcuts

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