solver

Imports

Imports #

"errors"
"io"
"sort"
"sync"
"context"
"io"
"sort"
"sync"

Constants & Variables

ErrInvalidInput var #

Package Errors Errors returned by the solver can be tested againts these errors using errors.Is

var ErrInvalidInput = *ast.CallExpr

ErrTimeout var #

Package Errors Errors returned by the solver can be tested againts these errors using errors.Is

var ErrTimeout = *ast.CallExpr

ErrUnknownPart var #

Package Errors Errors returned by the solver can be tested againts these errors using errors.Is

var ErrUnknownPart = *ast.CallExpr

keys var #

Keys of the solvers, sorted

var keys []string

keysCtx var #

Keys of the solvers with context support, sorted

var keysCtx []string

mu var #

Mutex guarding access to registry

var mu sync.RWMutex

muCtx var #

Mutex guarding access to registry of solvers with context support

var muCtx sync.RWMutex

registry var #

Registry of solvers

var registry = map[string]RegistryItem{...}

registryCtx var #

Registry of solvers with context support

var registryCtx = map[string]RegistryItemWithCtx{...}

Interfaces

PuzzleSolver interface #

Interface of Puzzle Solver

type PuzzleSolver interface {
Init(reader io.Reader) error
Solve(part int) (string, error)
}

PuzzleSolverWithCtx interface #

Interface of Puzzle Solver with context support

type PuzzleSolverWithCtx interface {
PuzzleSolver
InitCtx(ctx context.Context, reader io.Reader) error
SolveCtx(ctx context.Context, part int) (string, error)
}

Stepper interface #

Interface of Puzzle Solver supporting stepwise solving

type Stepper interface {
PuzzleSolver
Next() (string, error)
}

StepperWithCtx interface #

Interface of Puzzle Solver with support for context and stepwise solving

type StepperWithCtx interface {
PuzzleSolverWithCtx
Next(ctx context.Context) (string, error)
}

Structs

RegistryItem struct #

Registered solver

type RegistryItem struct {
Name string
Next bool
Constructor func() PuzzleSolver
}

RegistryItemPublic struct #

Registered solver for export purposes

type RegistryItemPublic struct {
Name string `json:"name"`
Next bool `json:"next"`
}

RegistryItemWithCtx struct #

Registered solver with context support

type RegistryItemWithCtx struct {
Name string
Next bool
Constructor func() PuzzleSolverWithCtx
}

Functions

ListRegistryItems function #

Lists registered keys

func ListRegistryItems() []RegistryItemPublic

ListRegistryItemsWithCtx function #

Lists registered keys of solvers with context support

func ListRegistryItemsWithCtx() []RegistryItemPublic

New function #

Factory for solvers

func New(name string) (PuzzleSolver, bool)

NewWithCtx function #

Factory for solvers with context

func NewWithCtx(name string) (PuzzleSolverWithCtx, bool)

Register function #

Registers a solver and check for supported interfaces Keeps the keys ordered

func Register(name string, constructor func() PuzzleSolver)

RegisterWithCtx function #

Registers a solver and check for supported interfaces Keeps the keys ordered

func RegisterWithCtx(name string, constructor func() PuzzleSolverWithCtx)