Advent of Code is an event run by Eric Wastl. For each day leading up to Christmas, programmers are tasked with solving two small problems each day. Find more information here.
- libopenblas-dev
You can run this project by calling
cargo +nightly build
./target/debug/AOC2023.exe -d [day number] -i [input file path]
or
cargo +nightly run -- -d [day number] -i [input file path]
To create a new solution file for a particular day, run ./start_day [day number]
By default, ./inputs/input_{day}.txt
will be used as the input file path. For example, day 01 will use ./inputs/input_01.txt
For more uses, run cargo run -- --help
.
Before contributing, run the following:
pip install pre-commit
pre-commit install
This will run a number of linting actions and tests before you can commit to ensure your code works.
An point with an arbitrary number of dimensions. AoC frequently features both 2D and 2D spaces that need to be simulated. Occasionally, there's a curveball in the form of a 4D space. These points assume that the spaces we need to represent are discrete - which is a safe bet since floating point operations in AoC are super rare.
Currently implements:
- addition, multiplication, magnitude
- Associated functions that return the offsets required to reach a point's neighbours:
card_offsets
returns all cardinal (non-diagonal) offsets- 'neighbour_offsets` returns all offsets
A grid with an arbitrary number of dimensions - using the above Pt
as a key in a Hashmap of arbitrary items. Includes some helpful features:
- Stores copies of
Pt
's neighbour offsets so we don't have to recalculate them each time. - Generator functions:
Default
, which creates an emptyGrid
of the specified dimensionsFrom
a vector ofPt
/valuesFrom
a vector of vectors/values. NOTE! We assume the vectors are of the same dimension as theGrid
!
- Default value that is returned if a point does not exist in a grid - helpful when we want to represent infinite space
merge
for combiningGrid
stransform
for applying a transformation to allPt
s in aGrid
(e.g. translation, multiplication, and God forbid, rotation.)bounds
for getting the minimum and maximum coordinate in each dimensionprint_2d
that creates a string representation of a 2D grid. Only 2D for now.