puzzle

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: GPL-3.0 Imports: 6 Imported by: 11

Documentation

Index

Constants

View Source
const (
	// PartAll means we want to solve both part 1 and part 2.
	PartAll = 0
	// Part1 means we want to solve part 1.
	Part1 = 1
	// Part2 means we want to solve part 2.
	Part2 = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Day

type Day interface {
	Part1() (string, error)
	Part2() (string, error)
	SetInput(value io.Reader) error
}

Day is the interface for daily solutions.

type InputParseError

type InputParseError struct {
	Message string
}

InputParseError occurs when something is not implemented.

func (InputParseError) Error

func (e InputParseError) Error() string

type Month

type Month struct {
	// contains filtered or unexported fields
}

Month manages daily solvers.

func NewMonth

func NewMonth() Month

NewMonth creates a new Month.

func (*Month) Get

func (m *Month) Get(day int) (Day, error)

Get solver for a day.

func (*Month) Register

func (m *Month) Register(day int, solver Day)

Register solver for a day.

type NoInputError

type NoInputError struct{}

NoInputError occurs when we have no input values.

func (NoInputError) Error

func (e NoInputError) Error() string

type NoSolutionError

type NoSolutionError struct{}

NoSolutionError occurs when we are unable to find a solution.

func (NoSolutionError) Error

func (e NoSolutionError) Error() string

type NotImplementedError

type NotImplementedError struct{}

NotImplementedError occurs when something is not implemented.

func (NotImplementedError) Error

func (e NotImplementedError) Error() string

type Solver

type Solver struct {
	Day  Day
	Part int
}

Solver is the main solver. All days and day parts will be called from here.

func NewSolver

func NewSolver(day Day, part int) Solver

NewSolver creates a new Solver for a specific day and part.

func (*Solver) Solve

func (s *Solver) Solve(value, file string) (string, error)

Solve simply solves the puzzle, if it's possible.

type UnkownDayError

type UnkownDayError struct {
	Day int
}

UnkownDayError occurs when given day is not defined.

func (UnkownDayError) Error

func (e UnkownDayError) Error() string

type UnkownPartError

type UnkownPartError struct {
	Day  Day
	Part int
}

UnkownPartError occurs when given part is not defined.

func (UnkownPartError) Error

func (e UnkownPartError) Error() string

Jump to

Keyboard shortcuts

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