https://github.com/cak/advent-of-code
Python solutions for Advent of Code challenges, organized by year.
https://github.com/cak/advent-of-code
Last synced: 4 months ago
JSON representation
Python solutions for Advent of Code challenges, organized by year.
- Host: GitHub
- URL: https://github.com/cak/advent-of-code
- Owner: cak
- License: mit
- Created: 2024-10-16T09:08:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-08T10:10:38.000Z (over 1 year ago)
- Last Synced: 2024-12-30T18:44:59.218Z (over 1 year ago)
- Language: Python
- Size: 95.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ Advent of Code ๐
Welcome to my festive repository, where code meets Christmas cheer! This collection holds my solutions for the [Advent of Code](https://adventofcode.com/) puzzles across multiple years. Join me as we unwrap new challenges each day of December, guided by the merry elves and sprinkled with holiday magic! โจ
## ๐
Advent of Code 2024 Progress (Goal: 20 Stars โญโญโญโญโญโญโญโญโญโญโญโญโญโญโญโญ)
### โญ Progress: 4/50 โญ
| Day | Stars | Solution |
| ------------------------------------------ | ----- | ---------------------------------------------------------------------------------- |
| [01](https://adventofcode.com/2024/day/1) | โญโญ | [Solution](https://github.com/cak/advent-of-code/blob/main/2024/day01/solution.py) |
| [02](https://adventofcode.com/2024/day/2) | โญโญ | [Solution](https://github.com/cak/advent-of-code/blob/main/2024/day02/solution.py) |
| [03](https://adventofcode.com/2024/day/3) | | |
| [04](https://adventofcode.com/2024/day/4) | | |
| [05](https://adventofcode.com/2024/day/5) | | |
| [06](https://adventofcode.com/2024/day/6) | | |
| [07](https://adventofcode.com/2024/day/7) | | |
| [08](https://adventofcode.com/2024/day/8) | | |
| [09](https://adventofcode.com/2024/day/9) | | |
| [10](https://adventofcode.com/2024/day/10) | | |
| [11](https://adventofcode.com/2024/day/11) | | |
| [12](https://adventofcode.com/2024/day/12) | | |
| [13](https://adventofcode.com/2024/day/13) | | |
| [14](https://adventofcode.com/2024/day/14) | | |
| [15](https://adventofcode.com/2024/day/15) | | |
| [16](https://adventofcode.com/2024/day/16) | | |
| [17](https://adventofcode.com/2024/day/17) | | |
| [18](https://adventofcode.com/2024/day/18) | | |
| [19](https://adventofcode.com/2024/day/19) | | |
| [20](https://adventofcode.com/2024/day/20) | | |
| [21](https://adventofcode.com/2024/day/21) | | |
| [22](https://adventofcode.com/2024/day/22) | | |
| [23](https://adventofcode.com/2024/day/23) | | |
| [24](https://adventofcode.com/2024/day/24) | | |
| [25](https://adventofcode.com/2024/day/25) | | |
---
### ๐ฏ Goal Tracker: Earn 20 Stars
| Milestone | Stars Earned | Status |
| --------------- | ------------ | -------------- |
| 1-10 Stars | 4/10 | ๐ฉ On Track |
| 11-20 Stars | 0/10 | ๐ฆ Not Started |
| Full Completion | 4/50 | โฌ |
## ๐ Folder Structure
Our repository is structured like a well-organized Christmas workshop! Each year contains folders for individual days, and the `elf` package houses utilities for puzzle-solving and automation:
```bash
advent-of-code/
โโโ 2016/
โ โโโ day01/
โ โโโ solution.py # ๐ Your main solution script for the day
โ โโโ input.txt # ๐ The puzzle input for the day
โ โโโ test_input.txt # ๐งช Example input for testing your solution
โ โโโ expected_output.txt # โ
The expected output for test input
โโโ elf/ # ๐งโโ๏ธ The elves' magical helpers!
โ โโโ cli/ # ๐
Command-line interface for automation
โ โโโ create_day.py # ๐๏ธ Script to create new day folders
โ โโโ fetch_input.py # ๐ Script to fetch puzzle inputs
โ โโโ run.py # ๐ Script to run a day's solution
โ โโโ submit.py # ๐ฏ Script to submit answers to Advent of Code
โ โโโ test.py # ๐งช Script to test solutions for correctness
โ โโโ templates/ # โจ Templates for new solution files
โ โโโ args.py # โ๏ธ Argument parsing template for solutions
โ โโโ solution_template.py # ๐ Template for daily solution scripts
โ โโโ utils.py # ๐งฐ General utility functions for helpers
โ โโโ input.py # ๐ Functions to fetch and cache puzzle inputs
โ โโโ config.py # โ๏ธ Configuration settings for the project
โ โโโ testing.py # ๐งช Tools for testing solutions
โ โโโ answer.py # ๐ฏ Helpers for answer validation and submission
โ โโโ exceptions.py # ๐จ Custom exception handling for the CLI
โโโ README.md # ๐ Documentation (you're here!)
โโโ LICENSE # ๐ Open source license
โโโ pyproject.toml # ๐ฆ Project dependencies and settings
โโโ uv.lock # ๐ Dependency lockfile
```
## ๐ ๏ธ Automating Tasks with the Elf CLI
The `elf` CLI is your all-in-one tool to manage Advent of Code puzzles. From creating folders to running tests, it makes solving puzzles joyful!
### Installing Dependencies
Before you start, install the required dependencies:
```bash
pip install -r requirements.txt
```
### Commands Overview
Run the CLI by executing:
```bash
python -m elf.cli.main [options]
```
Available commands:
- **`create-day`**: Create a new folder for a specific day.
- **`fetch-input`**: Fetch puzzle input for a specific day.
- **`run`**: Run the solution for a specific day and part.
- **`test`**: Test the solution using provided test inputs.
- **`submit`**: Submit your solution to Advent of Code.
### Command Details
#### 1. Create a New Day Folder
Set up a new folder for a day, complete with templates and input files:
```bash
python -m elf.cli.main create-day --output-dir
```
Example:
```bash
python -m elf.cli.main create-day 2016 5
```
#### 2. Fetch Puzzle Input
Fetch your personalized input for a day:
```bash
python -m elf.cli.main fetch-input
```
Example:
```bash
python -m elf.cli.main fetch-input 2016 5
```
#### 3. Run a Solution
Run your solution for a specific day and part:
```bash
python -m elf.cli.main run --part <1|2|both>
```
Examples:
```bash
python -m elf.cli.main run 2016 4 --part 1
python -m elf.cli.main run 2016 4 --part both
```
#### 4. Test Your Solution
Run tests using `test_input.txt` and `expected_output.txt`:
```bash
python -m elf.cli.main test
```
Example:
```bash
python -m elf.cli.main test 2016 4
```
#### 5. Submit Your Answer
Submit your solution directly to Advent of Code:
```bash
python -m elf.cli.main submit
```
Example:
```bash
python -m elf.cli.main submit 2016 4 1 12345
```
### Setting Up Your Session Token
To fetch inputs and submit answers, you'll need your Advent of Code session token:
1. Log in to [Advent of Code](https://adventofcode.com/) and copy your session token from the browser cookies.
2. Save it as an environment variable:
```bash
export AOC_SESSION_COOKIE='your_session_token_here'
```
**Note**: Keep your token secret to prevent unauthorized access.
## โจ Features of the `elf` Package
The `elf` package simplifies common tasks:
- **Input Handling**: Automatically fetch and cache puzzle inputs.
- **Testing Utilities**: Compare your output with expected results.
- **Template Management**: Quickly create new solution files.
- **Error Handling**: Gracefully manage exceptions.
Example usage in a solution:
```python
from elf import input, utils
def part1(data):
return sum(map(int, data.split()))
if __name__ == "__main__":
data = input.read_input_file("input.txt")
print("Part 1:", part1(data))
```
---
**May your Advent of Code journey be merry and bright! Happy coding! ๐
**