day05

package
v0.0.0-...-5d524ee Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Day05 = runner.NewDay(5, parseMaps, part1, part2).
	WithExpectedAnswers(226172555, 47909639)

Functions

This section is empty.

Types

type Map

type Map []Range

func (Map) Destination

func (m Map) Destination(source int) int

func (Map) String

func (m Map) String() string

func (Map) ToOffsets

func (m Map) ToOffsets() (rtn Offsets, err error)

type Maps

type Maps struct {
	Seeds                 []int
	SeedToSoil            Map
	SoilToFertilizer      Map
	FertilizerToWater     Map
	WaterToLight          Map
	LightToTemperature    Map
	TemperatureToHumidity Map
	HumidityToLocation    Map
}

type Offset

type Offset struct {
	// InputTo represents the inclusive upper range of this offset
	// The previous offsets InputTo +1 marks the start of this range
	//
	// If there is no previous offset, then the implicit start
	// is zero
	InputTo int

	// OffsetBy presents how much to offset the input
	// to create the output
	OffsetBy int
}

func (Offset) String

func (o Offset) String() string

type Offsets

type Offsets []Offset

func MapsToMergedOffset

func MapsToMergedOffset(maps ...Map) (rtn Offsets, err error)

func (Offsets) Compress

func (o Offsets) Compress() Offsets

Compress merges any offsets next to each other which have the same offset

func (Offsets) FindIdx

func (o Offsets) FindIdx(src int) (idx int)

FindIdx returns the index of the offset which contains the given src position

If no offset contains the given src position then -1 is returned

func (Offsets) ToMap

func (o Offsets) ToMap() Map

type Range

type Range struct {
	DestRangeStart int
	SrcRangeStart  int
	Length         int
}

func (Range) SourcesOverLap

func (r Range) SourcesOverLap(other Range) bool

SourcesOverLap returns true if these two ranges contain any overlap at all?

i.e. does any part of `r`'s SrcRangeStart -> (SrcRangeStart + Length) overlap with `other`'s SrcRangeStart -> (SrcRangeStart + Length)

func (Range) String

func (r Range) String() string

Jump to

Keyboard shortcuts

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