Advent of Code for some years with tests and utils etc. Code is in src/adventofcode, tests are in tests/
- Complete all puzzles (Doh)
You can use the adventofcode script to create the scaffolding and download the
input file for that day. If no year is given, the current year is set as a default.
A default year can also be stored in .env
.
An example:
adventofcode --year 2023 --create 20
Create a file .env
with the content:
# Store the session key here
AOC_SESSION = ""
# Select the year. If None, the current year is used.
AOC_YEAR = None
The variable AOC_SESSION
is the cookie from https://adventofcode.com/. This is available
in your browser after you've logged in.
To create a new day with the CookieCutter version run the command from the
adventofcode
directory.
Preferred option is to use the adventofcode
util, since this util also downloads the solution data.
To use cookiecutter:
cookiecutter template -f
Answer the questions:
adventofcode
: Accept default answer. This installs the result in the current directory.day
: Answer with the day you're working on, with leading zero. Eg: 07, 10, 31.year
: Answer with the year you're working on, eg 2023.directory_name
,file_name
,class_name
: Accept default answer.
This will create the correct files in the src
and tests
directories.
The -f
option is required to make the files in the current subdirectory.
When the project supports modules this is probably no longer needed.
Install the application with:
poetry install
Use tox
to run the tests, run adventofcode
to run the main application.
For dependencies we use Poetry Plugin: up.
poetry self add poetry-plugin-up
The plugin provides an up
command to update dependencies
poetry up --help
Update dependencies
poetry up
Update dependencies to latest available compatible versions
poetry up --latest
This project uses pre-commit. Pre-commit runs all the required tools before committing. This useful tool will be installed with:
pip install pre-commit
After installation run:
pre-commit install
Now every time before running git commit
the hooks defined in the
.pre-commit-config.yaml
file will be run before actually committing.
To run this manually, run:
pre-commit run --all-files
Update the .pre-commit-config.yaml
with the command:
pre-commit autoupdate
This command will go online and find the latest versions.