Collection of my Advent of Code solutions in an overkill project setup I forked π»π.
- Create a .session file at the root of the project and paste your AoC session in it.
- set up your local env
- run command "add-day" to start fetching inputs from AoC
- Solutions are timed with the help of a decorator using
time.perf_counter - Solution and time are printed to console using the
richpackage withtruecolor - Solution profiler decorator using
Cprofileandpstats - Automatic listing of completed solutions in the README
- Automatic changelog, using semantic versioning and the conventional commit specification
- Pip installable (
pip install -e .) with:- A
run-allscript, which dynamically calls every solution in everyadventofcode.year_*.day_*module - An
add-dayscript, which add a solution day file using a template and downloads the input data from the AOC site automatically
- A
- Type checked (
mypy) and linted (flake8) - Tested against multiple python versions using
toxon each push to master and pull request
What's Christmas without decorations? π
The solution timer times the solution using time.perf_counter and outputs the answer and the duration to the console
Output:
2015 day 09 part 01: 251 in 0.1356 ms
The solution profiler runs the cProfiler against the solution and outputs the profiler stats using pstats to the console.
It takes an optional amount kwarg to set the amount of stats to display, and an optional sort kwarg to set the sorting to either
time or cumulative.
The add-day script creates a file based on a 'solution day' template into the correct year module. If no input is found
for that day, it will automatically download the input and save it in the inputs' directory. Note: this only works if the
session cookie is stored in .session. To get this value:
- Go to the AOC site.
- Make sure you're logged in, every user has unique input data
- View the cookies and copy the value of the
sessioncookie. - Paste the cookie value into the
.sessionfile
If you run the command without arguments, it will add input of the current day.
Example:
(venv) add-day --year 2015 --day 14Output:
(venv) [adventofcode] add-day 2015 14 master β β β±
Creating solution day file for year 2015 day 14
Wrote template to /Users/marcelblijleven/code/github.com/marcelblijleven/adventofcode/src/adventofcode/year_2015/day_14_2015.py
Input data already exists for year 2015 day 14, skipping download
The clean-repo script is used to delete all solutions and inputs from the project. This can be useful if you want to start over,
or if you've just forked this repo. The clean-repo command is run in 'dry run mode' by default, to disable it and actually
start deleting directories and files, use:
(venv) clean-repo --dry-run false