GithubHelp home page GithubHelp logo

aod / elver Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 162 KB

๐ŸŽ„๐Ÿง Run your Advent of Code solutions in Go with a single command

Home Page: https://adventofcode.com

License: MIT License

Go 100.00%
advent-of-code aoc-runner go-aoc aoc-util aoc-cli golang runner cli solvers advent

elver's Introduction


Features | How does it work? | Getting started | Examples | Similar


GitHub GitHub go.mod Go version GitHub tag (latest by date) Go PkgGoDev

NOTE: only supported on Linux, FreeBSD, and macOS due to the use of built-in plugin package.

Run your Go Advent of Code solutions with a single command. Write your solution and Elver will take care of the rest.

Features

  • Automatically downloads and caches the input
  • Runs your latest solution and times it
  • Automatic benchmarking of your solution
  • 0 third party dependencies

How does it work?

Elver uses plugin build mode to dynamically look up the solutions. These must reside in an Advent of Code folder under the main package.

Getting started

1. Install

$ go get github.com/aod/elver

2. Session token

Your https://adventofcode.com session token is required for downloading and caching the inputs.

2.A Environment variable

Set your Advent of Code session token in the environment variable AOC_SESSION.

2.B Config file

Alternatively you can store it in the aoc_session file in the following directory:

  • Linux: $HOME/.config/elver/
  • MacOS: /Library/Application Support/elver/
  • Windows: %AppData%\elver\

3. Project structure

A solution for a day in an Advent of Code year is represented by 2 solvers for part A and B. All solvers are functions which satisfy the same signature where interface{} is the output:

func (input string) (interface{}, error)

For the plugin build mode to work correctly all solvers must be exported. The name of a solver is also very important for elver to work properly. It's name must satisfy the following set of rules:

  • Starts with Day
  • Followed by a valid Advent of Code day
    • Within (inclusive) range of 1..25
  • Ends with A for part 1 or B for part 2.

Solvers are workspaced by the Advent of Code year which is also used as the folder name.

Example

// /2015/01.go
package main

import "errors"

func Day1A(input string) (interface{}, error) {
    return 42, nil
}

func Day1B(input string) (interface{}, error) {
    return nil, errors.New("Not implemented")
}

Running Elver in the root directory will output something like the following:

$ elver
AOC 2015
Day 1 A (312ns):
42
Day 1 B (956ns):
[ERROR] Not implemented

Benchmarking

Run Elver with the -b flag to benchmark your latest solution:

$ elver -b
AOC 2015
Day 1 A (N=231919370, 5 ns/op, 0 bytes/op, 0 allocs/op):
42
Day 1 B (N=0, 0 ns/op, 0 bytes/op, 0 allocs/op):
[ERROR] Not implemented

Examples

Running the latest solvers:

$ elver

Running the latest solvers of a specific year:

$ elver -y 2017

Running the latest solvers of a specific day:

$ elver -d 21

Running the specific solvers of a year and day:

$ elver -y 2017 -d 21

Benchmarking the solvers by adding the -b flag

$ elver -b
// Works with any combination of the previously mentioned flags e.g.:
$ elver -y 2017 -d 21 -b

Similar

These type of utility tools for Advent of Code also exist for other programming languages like cargo-aoc (Rust) and aocd (Python). Elver finds inspiration in these awesome projects so be sure to check them out as well!

elver's People

Contributors

aod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elver's Issues

Year and/or day specification using flags

Enable -y and -d flags to let the user specify which solution to run:

  • elver -y 2019 runs the latest solution for 2019
  • elver -y 2019 -d 5 runs day 5 of 2019
  • Any invalid year/day shows the user an error msg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.