Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wilhelmagren/advent-of-code

A streamlined Python package for advent-of-code. Automatic puzzle-input requests and validation of setup. All made to help you save christmas as easily as possible!
https://github.com/wilhelmagren/advent-of-code

advent-of-code automation statistics

Last synced: about 2 months ago
JSON representation

A streamlined Python package for advent-of-code. Automatic puzzle-input requests and validation of setup. All made to help you save christmas as easily as possible!

Awesome Lists containing this project

README

        

# Advent-of-Code package for Python πŸŽ„ 🌟
This repository contains the `adventofcode` python package which enables a streamlined and simple coding experience so that you can help save christmas! It is written using mostly built-in libraries, except for the dependency of [numpy](https://numpy.org/). If you find any bug or have suggestions on how to improve this package, go down to the contact section to see where you can reach me. Otherwise, just clone it and create a PR of the feature you want to add or fix.

## Directory setup
To run the streamlined pipeline it requires a specific directory structure. All data files should follow the naming convention of `d.in` and be placed in `data//`. All solutions should follow the naming convention `dp.py` and be placed in `solutions//`. The package has a module for setting up the required directory structure automatically, but if you want to manually transfer files/solutions, make sure that your directory looks accordingly:
```
your-repository/
β”œβ”€β”€ adventofcode/
β”‚ β”œβ”€β”€ __init__.py
| β”œβ”€β”€ datautil.py
| β”œβ”€β”€ setup.py
β”‚ β”œβ”€β”€ solver.py
β”‚ └── utils.py
β”œβ”€β”€ data/
β”‚ β”œβ”€β”€ 2020/
| | └── ...
β”‚ └── 2021/
| β”œβ”€β”€ d1.in
| β”œβ”€β”€ d2.in
| └── ...
β”œβ”€β”€ solutions/
β”‚ β”œβ”€β”€ 2020/
| | └── ...
β”‚ └── 2021/
| β”œβ”€β”€ d1p1.py
| β”œβ”€β”€ d1p2.py
| β”œβ”€β”€ d2p1.py
| └── ...
β”œβ”€β”€ aoc.py
└── session.token
```
The `session.token` file is required so that you can autoamtically get the input file for the problem which you are trying to solve, if it already doesn't exist. It should contain one line with your user session cookie. This can be found if you inspect the network packages when accessing this [link](https://adventofcode.com/2021/day/3/input) whilst logged in to the website.

## How to run
All solution implementation files should also follow a specific form. An example can be found in the `template-solution.py` file. Running the pipeline is as easy as invoking the file `aoc.py` with arguments specifying what you want to do. For example if you want to run your solutions for day 1 of 2021 AoC, run `python aoc.py --years 2021 --day 1 --parts 1 2 --verbose --run`. If you haven't manually downloaded the input files for those solutions, don't worry- the package will do that for you! All available arguments can be seen below:
```
usage: python aoc.py [-h] [-v] [-s] [-r] [-y [YEARS ...]] [-d [DAYS ...]] [-p [PARTS ...]]

Streamlined Advent of Code pipeline so that you can help save christmas as easily as possible!

optional arguments:
-h, --help show this help message and exit
-v, --verbose print time-stats for your solutions
-s, --setup setup the required directory structures
-r, --run run the solver on your solutions
-y [YEARS ...], --years [YEARS ...]
set what years to solve problems from
-d [DAYS ...], --days [DAYS ...]
set what days to solve
-p [PARTS ...], --parts [PARTS ...]
set what parts of a day to solve

We have to save christmas!
```

## Contact and license
If you have any suggestions on how to improve this pipeline, contact me or create a pull request!

Author: Wilhelm Γ…gren, [email protected]

License: GNU General Public License v3.0