Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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!
- Host: GitHub
- URL: https://github.com/wilhelmagren/advent-of-code
- Owner: wilhelmagren
- License: gpl-3.0
- Created: 2021-11-30T20:52:37.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T19:46:56.000Z (about 1 year ago)
- Last Synced: 2024-10-13T14:40:35.228Z (2 months ago)
- Topics: advent-of-code, automation, statistics
- Language: Python
- Homepage:
- Size: 286 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 solveWe 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