d5

Imports

Imports #

"advent2024/pkg/solver"
"bufio"
"fmt"
"io"
"log"
"slices"
"strconv"
"strings"
"advent2024/pkg/solver"
"context"
"fmt"
"io"
"slices"
"strconv"

Constants & Variables

RECORDS const #

const RECORDS section = 1

RULES const #

const RULES section = 0

day var #

var day = "d5"

Type Aliases

section type #

type section int

Structs

PuzzleStruct struct #

type PuzzleStruct struct {
rules map[int]Rules
updates [][]int
}

PuzzleStructWithCtx struct #

type PuzzleStructWithCtx struct {
PuzzleStruct
}

Rules struct #

type Rules struct {
before map[int]bool
after map[int]bool
}

Functions

Init method #

func (p *PuzzleStruct) Init(reader io.Reader) error

InitCtx method #

func (p *PuzzleStructWithCtx) InitCtx(ctx context.Context, reader io.Reader) error

NewSolver function #

func NewSolver() *PuzzleStruct

NewSolverWithCtx function #

func NewSolverWithCtx() *PuzzleStructWithCtx

Solve method #

func (p *PuzzleStruct) Solve(part int) (string, error)

SolveCtx method #

func (p *PuzzleStructWithCtx) SolveCtx(ctx context.Context, part int) (string, error)

init function #

func init()

init function #

func init()

newRules function #

func newRules() Rules

parseInput function #

func parseInput(sc *bufio.Scanner) (*[2][][]int, error)

processRules function #

func processRules(parsedRules [][]int) map[int]Rules

sortFunc method #

func (p *PuzzleStruct) sortFunc() (func(a int, b int) int)

updateRules method #

func (r *Rules) updateRules(before []int, after []int)

validateInput function #

func validateInput(rules *map[int]Rules, updates *[][]int) error