d05

package
v0.0.0-...-b6440bf Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseNumbers

func ParseNumbers(data string) ([]int, error)

func ReadExample

func ReadExample() []string

func ReadInput

func ReadInput() []string

Types

type Almanac

type Almanac struct {
	SeedRanges []*SeedRange

	// Head map is the seed-to-soil map
	Head *Map

	// Tail map is the humidity-to-location map
	Tail *Map
}

func ParseAlmanac

func ParseAlmanac(data []string) (*Almanac, error)

func (*Almanac) ContainsSeed

func (a *Almanac) ContainsSeed(seed int) bool

func (*Almanac) LookupDstID

func (a *Almanac) LookupDstID(src, dst Category, srcID int) int

func (*Almanac) LookupSrcID

func (a *Almanac) LookupSrcID(dst, src Category, dstID int) int

func (*Almanac) SeedAtLowestLocation

func (a *Almanac) SeedAtLowestLocation() (seed int, location int)

type Category

type Category string
const (
	CategorySEED        Category = "seed"
	CategorySOIL        Category = "soil"
	CategoryFERTILIZER  Category = "fertilizer"
	CategoryWATER       Category = "water"
	CategoryLIGHT       Category = "light"
	CategoryTEMPERATURE Category = "temperature"
	CategoryHUMIDITY    Category = "humidity"
	CategoryLOCATION    Category = "location"
)

type Map

type Map struct {
	Src, Dst Category
	Ranges   []*Range

	Prev *Map
	Next *Map
}

func (*Map) DstID

func (m *Map) DstID(srcID int) int

DstID returns the destination ID for the given source ID.

func (*Map) SrcID

func (m *Map) SrcID(dstID int) int

SrcID returns the source ID for the given destination ID.

func (*Map) String

func (m *Map) String() string

type Range

type Range struct {
	// DstNum is the destination start number.
	DstNum int
	// SrcNum is the source start number.
	SrcNum int
	// Len is the range length.
	Len int
}

func (*Range) DstID

func (r *Range) DstID(srcID int) (int, bool)

func (*Range) SrcID

func (r *Range) SrcID(dstID int) (int, bool)

type SeedRange

type SeedRange struct {
	// Num is the start number of the seed range
	Num int
	// Len is the length of the seed range
	Len int
}

func (*SeedRange) ContainsSeed

func (r *SeedRange) ContainsSeed(seed int) bool

Jump to

Keyboard shortcuts

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