puzzles

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package puzzles declares common interface for puzzle solutions and functionality for register and run them.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidPzzlName means that such puzzle not exist.
	ErrInvalidPzzlName = errors.New("invalid puzzle name")
	// ErrInvalidYear means that such year not exist.
	ErrInvalidYear = errors.New("invalid year")
)
View Source
var ErrNotImplemented = errors.New("not implemented")

ErrNotImplemented signal that puzzle in not implemented yet.

Functions

func GetYears added in v0.2.0

func GetYears() []string

GetYears returns list of available years for solvers.

func MakeName

func MakeName(year string, puzzle string) (string, error)

MakeName builds puzzle name according to year and puzzle passed.

func NamesByYear added in v0.2.0

func NamesByYear(year string) []string

NamesByYear returns a sorted list of the names of the registered puzzle solvers for passed year.

func Register

func Register(solver Solver)

Register makes a puzzle solver available by the provided name. If Register is called twice with the same name or if solver is nil, it panics.

func UnregisterAllSolvers

func UnregisterAllSolvers(tb testing.TB)

UnregisterAllSolvers cleans up registered solvers. Use for testing only.

Types

type Result

type Result struct {
	Year  string
	Name  string
	Part1 string
	Part2 string
}

Result represents puzzle solution result.

func Run

func Run(solver Solver, input io.Reader) (Result, error)

Run uses solver of puzzle and path to input.

type Solver

type Solver interface {
	Part1(input io.Reader) (string, error)
	Part2(input io.Reader) (string, error)
	Name() string
	Year() string
}

Solver represents solutions for puzzles methods.

func GetSolver

func GetSolver(year string, name string) (Solver, error)

GetSolver returns registered solver by passed puzzle name.

Directories

Path Synopsis
Package solutions registers solutions of puzzles.
Package solutions registers solutions of puzzles.
2019/day01
Package day01 solves https://adventofcode.com/2019/day/1
Package day01 solves https://adventofcode.com/2019/day/1
2019/day02
Package day02 solves https://adventofcode.com/2019/day/2
Package day02 solves https://adventofcode.com/2019/day/2
2019/day03
Package day03 solves https://adventofcode.com/2019/day/3
Package day03 solves https://adventofcode.com/2019/day/3
2019/day04
Package day04 solves https://adventofcode.com/2019/day/4
Package day04 solves https://adventofcode.com/2019/day/4
utils
intcomputer
Package intcomputer provides functionality for Intcode programs calculation Intcode programs are given as a list of integers; these values are used as the initial state for the computer's memory.
Package intcomputer provides functionality for Intcode programs calculation Intcode programs are given as a list of integers; these values are used as the initial state for the computer's memory.

Jump to

Keyboard shortcuts

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