Documentation
¶
Overview ¶
Package advent contains all advent of code related functionality.
Index ¶
- Constants
- Variables
- func NormalizationFactor() float64
- func ParseURL(url string) (int, int, error)
- func WithDir(dir string) func(*Exercise)
- func WithDownloadLanguage(lang string) func(*Downloader)
- func WithExerciseDir(dir string) func(*Benchmarker)
- func WithInputFile(file string) func(*Exercise)
- func WithLanguage(lang string) func(*Exercise)
- func WithOverwrites(o *Overwrites) func(*Downloader)
- func WithSkipImpl(skip bool) func(*Downloader)
- func WithURL(url string) func(*Downloader)
- type Answer
- type BenchmarkData
- type Benchmarker
- type Data
- type Downloader
- type Exercise
- type ImplementationData
- type Overwrites
- type PartData
- type Test
- type TestCase
Constants ¶
Variables ¶
var ( ErrEmptyLanguage = errors.New("no language specified") ErrNotFound = afero.ErrFileNotFound ErrNotImplemented = errors.New("not implemented") ErrNoRunner = errors.New("no runner available") ErrInvalidData = errors.New("invalid data") ErrNoImplementations = errors.New("no implementations found") ErrLoadInfo = errors.New("load info") )
var ( ErrNotConfigured = errors.New("not configured") ErrNilConfiguration = errors.New("nil configuration") ErrHTTPRequest = errors.New("http request") ErrHTTPResponse = errors.New("http response") ErrInvalidURL = errors.New("invalid URL") ErrInvalidLanguage = errors.New("invalid language") )
var ErrRunnerStart = errors.New("runner start error")
Functions ¶
func NormalizationFactor ¶
func NormalizationFactor() float64
func WithDownloadLanguage ¶
func WithDownloadLanguage(lang string) func(*Downloader)
WithDownloadLanguage sets the language for the exercise implementation. This will override any language set in the configuration.
func WithExerciseDir ¶
func WithExerciseDir(dir string) func(*Benchmarker)
func WithInputFile ¶
func WithLanguage ¶
func WithOverwrites ¶
func WithOverwrites(o *Overwrites) func(*Downloader)
WithOverwrites sets the files that can be overwritten if already in place.
func WithSkipImpl ¶
func WithSkipImpl(skip bool) func(*Downloader)
WithSkipImpl sets the downloader to skip creating implementation files and structure.
func WithURL ¶
func WithURL(url string) func(*Downloader)
WithURL sets the exercise URL to download.
Types ¶
type BenchmarkData ¶
type BenchmarkData struct { Date time.Time `json:"run-date,omitempty"` // Dir string `json:"dir"` Title string `json:"title"` Year int `json:"year,omitempty"` Day int `json:"day"` Runs int `json:"numRuns"` Normalization float64 `json:"normalization,omitempty"` Implementations []*ImplementationData `json:"implementations"` }
func (*BenchmarkData) String ¶
func (b *BenchmarkData) String() string
type Benchmarker ¶
type Benchmarker struct { *Exercise // contains filtered or unexported fields }
func NewBenchmarker ¶
func NewBenchmarker(config krampus.ExerciseConfiguration, options ...func(*Benchmarker)) (*Benchmarker, error)
type Data ¶
type Data struct { InputData string `json:"-"` InputFileName string `json:"inputFile"` TestCases TestCase `json:"testCases"` Answers Answer `json:"answers,omitempty"` }
Data contains the relative path to exercise input and the specific test case data for an exercise.
type Downloader ¶
type Downloader struct { *Exercise // contains filtered or unexported fields }
func NewDownloader ¶
func NewDownloader(config krampus.DownloadConfiguration, options ...func(*Downloader)) (*Downloader, error)
func (*Downloader) Download ¶
func (d *Downloader) Download() error
type Exercise ¶
type Exercise struct { ID string `json:"id"` Title string `json:"title"` Language string `json:"-"` Year int `json:"year"` Day int `json:"day"` URL string `json:"url"` Data *Data `json:"data"` Path string `json:"-"` // contains filtered or unexported fields }
func New ¶
func New(config krampus.ExerciseConfiguration, options ...func(*Exercise)) (*Exercise, error)
func (*Exercise) Dir ¶
Dir returns the base of the exercise directory. It will return an empty string if the exercise does not exist.
Example: 01-someExerciseTitle.
func (*Exercise) GetImplementations ¶
GetImplementations returns a list of available implementations for the exercise.
type ImplementationData ¶
type ImplementationData struct { Name string `json:"name"` PartOne *PartData `json:"part-one"` PartTwo *PartData `json:"part-two,omitempty"` }
func (*ImplementationData) String ¶
func (i *ImplementationData) String() string
type Overwrites ¶
type Overwrites struct {
Input bool
}