This repository implements solutions to the puzzles in the 2015 Advent of Code using Python.
This was a vehicle to learn Python, so I presume not everything done here will be deemed idiomatic by language specialists.
Generally speaking, the solutions are organised predominantly for comprehension. They strive to arrive at an answer in a reasonable period of time, but they typically prioritise optimal understanding over optimal performance.
The examples are representative of my thinking and coding style.
The project requires python 3.12.4
, but any reasonably current version of
Python will likely work. I tend to code done the middle of any language
specification.
If you use a Python manager that responds to .tool-versions
, you should
be switched to correct version automatically. I recommend ASDF
for those on platforms that support it.
Python's package manager should be included in the installation, but it is often slightly out of date. Let's ensure we have the latest and greatest.
$ pip install --upgrade pip
Next we need to install and create a virtual environment for the project. This will create a clean space for managing our python dependencies. This library should also be included automatically in your Python installation.
$ python -m venv venv
Now, load your virtual environment.
source venv/bin/activate
Finally, install the project dependencies.
$ pip install --upgrade pip
$ pip install -r requirements.txt
- data: Puzzle input organised by day
- site: A local version of the instruction pages
- src: Puzzle solutions organised by day
- test: A simple set of regression tests
Modify the code in main.py
to run the solutions for the appropriate
day. Then, simply execute the following command in your terminal from the
project root.
$ make run
The only tests are a set of checks to verify solved puzzles.
I often refactor my solutions for clarity (or as I learn new techniques in subsequent puzzles), so it is helpful to have these simple tests to give my refactors some confidence.
To execute the tests, simply execute the following command in your terminal from the project root.
$ make verify