For sharing my adventofcode.com solutions
There is a visualizations
project meant to be called from a puzzle to
generate a visualization. There is also a visualizations-server
project that
uses Scala.js and vite to create more complex visualization code.
Visualizations may be viewed via the runner with a sbt run visualization <day> <name>
command.
It will start a web server and automatically open the browser to the page.
To develop a visualization:
# npm install
# npm run dev
To build it:
# npm run build
# npm run preview
Runs the puzzles. Run run --help
from the sbt console of one of the project years for options.
You can manually manipulate the database with sqlite3 advent.db
.
A set of useful algorithms for solving the puzzles.
Automatically parses puzzle input according to the given type.
Adds four type classes that ease working with puzzle input:
Read[A]
: Converts aString
to anA
.ReadSeq[C[_]]
: Converts aString
to a containerC[A]
.ReadProduct[T]
: Converts aString
to a tuple or case classT
.Show[A]
: Converts anA
into aString
.
There are three useful overloads of Read.apply
for different situations:
given Read[MyCaseClass] = Read(regex)
Uses the match groups of the regex to populate the fields of the case class.given Read[MyCaseClass] = Read(delimiter)
Splits the input by the delimiter and assigns to each field of the case class.given Read[List[A]] = Read(delimiter)
Splits the input by the delimiter to populate each element of the List.
The first two work with any product, so case classes and tuples. The last one
works with any collection with a ReadSeq
instance, which is currently
Vector
, List
, and Set
.
Read
also has a .map
method, which is useful for transforming the data in
a more complex way than delimiters or regular expressions, such as for
building a Graph
. It can help avoid repetition in the puzzle parts.
This repo follows the automation guidelines on the /r/adventofcode community wiki.
Specifically:
- Does not require throttling because does not make outbound calls except when a human requests to run a new puzzle.
- Once inputs are downloaded, they are cached locally (setInput).
- Previous guesses are remembered, to prevent submitting known-incorrect answers.
- The User-Agent header is set to me (request).
- Includes this notice in the README.
- Only stores inputs and examples in a local database file that is not committed to source control.