d08

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//go:embed example1.txt
	Example1Data []byte

	//go:embed example2.txt
	Example2Data []byte

	//go:embed example3.txt
	Example3Data []byte

	//go:embed input.txt
	InputData []byte
)

Functions

func GCD

func GCD(a, b int) int

func LCM

func LCM(a, b int) int

func NodeEndsWithZ

func NodeEndsWithZ(node *Node) bool

func NodeZZZ

func NodeZZZ(node *Node) bool

func ReadData

func ReadData(data []byte) []string

Types

type Map

type Map struct {
	Path []byte

	// Nodes are the nodes in the graph.
	Nodes map[string]*Node

	// StartNodes are nodes with an 'A' suffix.
	StartNodes []*Node
}

func ParseData

func ParseData(data []string) (Map, error)

func (*Map) Walk

func (m *Map) Walk(start string, isEnd func(*Node) bool) int

func (*Map) WalkStartNodes

func (m *Map) WalkStartNodes() int

type Node

type Node struct {
	Pos string
	L   *Node
	R   *Node
}

func (*Node) Next

func (i *Node) Next(path byte) *Node

Jump to

Keyboard shortcuts

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