Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dylanljones/adventofcode
🎄 My solutions for Advent of Code (https://adventofcode.com)
https://github.com/dylanljones/adventofcode
Last synced: 16 days ago
JSON representation
🎄 My solutions for Advent of Code (https://adventofcode.com)
- Host: GitHub
- URL: https://github.com/dylanljones/adventofcode
- Owner: dylanljones
- Created: 2022-12-01T16:59:11.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-18T11:02:22.000Z (11 months ago)
- Last Synced: 2023-12-18T12:24:14.381Z (11 months ago)
- Language: Python
- Homepage:
- Size: 421 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Advent of Code
=================[![AoC 2021](https://img.shields.io/badge/⭐_2021-34-yellow)](https://adventofcode.com/2021)
[![AoC 2022](https://img.shields.io/badge/⭐_2022-50-yellow)](https://adventofcode.com/2022)
[![AoC 2023](https://img.shields.io/badge/⭐_2023-50-yellow)](https://adventofcode.com/2023)🎄 My solutions for [Advent of Code]
## Python interface
The solutions in Python all use the included Python interface
### Advent of Code Client
This project includes a client for scraping data from [Advent of Code] and
submitting answers.> Please do not spam the servers and cache the data!
> Caching is handled by the ``Puzzle`` object, not the client.Since the puzzle inputs differ by user, a session token has to be supplied.
It can be either passed as argument to the client or stored in a file called
``token.txt``, located in the project root or the individual directories.Example usage:
````python
from aoc import Clientclient = Client()
# Load puzzle data
info = client.get_puzzle(year=2015, day=1)
input_data = client.get_input(year=2015, day=1)
user_stats = client.get_user_stats(year=2015)
# Compute your answers
...
# Submit your answers
client.submit(year=2015, day=1, part=1, answer=anser_part_1)
client.submit(year=2015, day=1, part=2, answer=anser_part_2)
````### Advent of Code Puzzles
You can use the included ``Puzzle`` object to automatically download and cache the
puzzle data and can be used to supply and submit answers.````python
from aoc import Puzzleclass Solution(Puzzle):
year = 2015
day = 1def solution_1(self, data: str):
...
return answerdef solution_2(self, data: str):
...
return answer
````The puzzle can then be run. Before submitting the answer to [Advent of Code], the solution
is checked against the example input and solution:
````python
sol = Solution()
sol.run(test_only=False, text=True)
````If the first solution was correct, the ``Puzzle`` object will update the puzzle info
before running the second part.You can initialize a solution directory with the included CLI script:
```bash
python -m aoc -d 1 -y 2015
```[Advent of Code]: https://adventofcode.com