day08

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidInstruction = errors.New("invalid instruction")
	ErrInvalidNodeName    = errors.New("invalid node name")
	ErrNodeNotFound       = errors.New("node not found")
)
View Source
var (
	InstructionLeft, _  = NewInstruction('L')
	InstructionRight, _ = NewInstruction('R')
	NodeIdAAA, _        = NewNodeId("AAA")
	NodeIdZZZ, _        = NewNodeId("ZZZ")
)

Functions

func NewParser

func NewParser() *participle.Parser[Network]

Types

type Instruction

type Instruction uint8

func NewInstruction

func NewInstruction(instructionCode rune) (result Instruction, err error)

func (*Instruction) Capture

func (instruction *Instruction) Capture(values []string) error

type Network

type Network struct {
	Instructions []Instruction `parser:"@InstructionCode+ Whitespace"`
	Nodes        []Node        `parser:"@@+"`
}

func (*Network) Part1

func (network *Network) Part1() (result int, err error)

func (*Network) Part2

func (network *Network) Part2() (result int, err error)

type Node

type Node struct {
	Id      NodeId `parser:"@NodeName '=' '(' "`
	LeftId  NodeId `parser:"@NodeName ','     "`
	RightId NodeId `parser:"@NodeName ')'     "`
}

type NodeId

type NodeId uint16

func NewNodeId

func NewNodeId(nodeName string) (result NodeId, err error)

func (*NodeId) Capture

func (nodeId *NodeId) Capture(values []string) error

func (NodeId) EndsWithA

func (nodeId NodeId) EndsWithA() bool

func (NodeId) EndsWithZ

func (nodeId NodeId) EndsWithZ() bool

Jump to

Keyboard shortcuts

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