Advent of Code Python Starter

A tamplate for Advent of Code write in Python.


The project use poetry for project manager.
Clone this repository and run poetry install for install dependencies:

$ git clone aoc-python
$ cd aoc-python

# install dependencies
$ poetry install

# run tests from day01
$ poetry run pytest tests/

# run the day01
# poetry run python -m aoc.day01


You can generate all necesary files for use in the event with a simple

$ poetry run python -m aoc.gen day01

This command generate these files:

* creating /aoc/day01/resources/input.txt
* creating /aoc/day01/
* creating /aoc/day01/
* creating /aoc/day01/
* creating /aoc/day01/
* creating /tests/
  • /aoc/day01/resources/input.txt: you can insert here the input data.
  • /aoc/day01/ is the main module.
  • /aoc/day01/ solution for part 1.
  • /aoc/day01/ solution for part 2.
  • /aoc/day01/ you can write the challenge statement.
  • /tests/ is the module where you write the tests.


You can configure the automatic input download from the Advent of Code
session token.

For dowload the inputs from web, you needs to set the environment var
AOC_SESSION. You can to get the session token from the cookie web browser.

Also can you set the AOC_YEAR to select a certain year.
(It is not mandatory use the AOC_YEAR, aoc.gen can get the year automatically)

You can set an .env file with these variables.

You can avoid the generation of the folder __pycache__ set this environment
variable export PYTHONDONTWRITEBYTECODE=1 o pass the -B flag
after python command.

Folder structure:

├── aoc
│   └── day01
│       ├──
│       ├──
│       ├──
│       ├──
│       └── resources
│           └── input.txt
└── tests

Happy coding!

MIT License


View Github