Skip to content

tyler-hoffman/aoc-2023

Repository files navigation

advent of code 2023

Python 3.12 edition

Notes on the repo

  • Package management is done with Poetry
  • Utils in the utils/ directory can/should be used to bootstrap new directories/files for solutions
  • Some parts of this repo are specific to the problems I receive (e.g. this won't entirely scale for non-me people)
    • utils in the utils/ derectory require advent-of-code-data, which relies on my session cookie. So don't use those unless you are me.
    • To make refactoring safer, after completing a problem, a test will be added asserting that my input produces the right output. If you aren't me, your input/output probably don't match.
  • In terms of code structure, I treat the solution as a property of the problem and its inputs, modeled using dataclasses. Maybe kind of misusing them, but I kinda dig it.

Getting started

  1. Make sure you have Poetry installed
  2. poetry install
  3. If you are using utils that use advent-of-code-data, have my adventofcode session cookie stored in ~/.config/aocd/token (note that this may be tricky if you are not me)

Commands to run

Purpose Command
Set up pre-commit hooks poetry run pre-commit install
Run all tests poetry run pytest
Run specific test file poetry run pytest <FILE>
Format code poetry run ruff format .
Lint code poetry run ruff check . --fix
Typecheck poetry run pyright .
Run solution file poetry run python -m aoc_2023.day_<DAY>.<PART>
Bootstrap files for new problem poetry run python -m utils.create_files -d <DAY> -p <PART>
Submit solution poetry run python -m utils.submit -d <DAY> -p <PART>

Note: <DAY> above should use 2 digits, prepending a 0 for numbers below 10.

Handy Links

About those input.txt and from_prompt.py files...

I'm encrypting data/text from the site to respect Eric's wishes. To do so, I'm using git-crypt with symmetric encryption. My key is stored locally, and for CI, I'm adding a base64 encoded string of the file as an environment variable. That gets decrypted and written to disk in CI so that it can run tests against my actual input. Like some other parts of this repo, this may make things hard if you are not me.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages