d6

Imports

Imports #

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

Constants & Variables

DOWN const #

const DOWN Orientation = 2

LEFT const #

const LEFT Orientation = 3

UP const #

const UP Orientation = 0

day var #

var day = "d6"

Type Aliases

Orientation type #

type Orientation int

Structs

Coords struct #

type Coords struct {
x int
y int
}

Guard struct #

type Guard struct {
c Coords
o Orientation
visited map[Coords][4]bool
}

LoopingError struct #

type LoopingError struct {
Resource string
}

NotInFieldError struct #

type NotInFieldError struct {
Resource string
}

PuzzleStruct struct #

type PuzzleStruct struct {
field [][]byte
guard Guard
}

PuzzleStructWithCtx struct #

type PuzzleStructWithCtx struct {
PuzzleStruct
}

Functions

Byte method #

func (o Orientation) Byte() byte

Error method #

func (e NotInFieldError) Error() string

Error method #

func (e LoopingError) Error() string

Init method #

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

InitCtx method #

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

Move method #

func (g *Guard) Move(field *[][]byte) error

NewGuard function #

func NewGuard(x int, y int, o Orientation) Guard

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)

findGuard function #

func findGuard(field *[][]byte) (int, int, error)

init function #

func init()

init function #

func init()

parseInput function #

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

toOrientation function #

func toOrientation(b byte) (Orientation, error)

validateInput function #

func validateInput(field *[][]byte) error