Welcome to my festive repository, where code meets Christmas cheer! This collection holds my solutions for the Advent of Code 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! β¨
| Day | Stars | Solution |
|---|---|---|
| 01 | ββ | Solution |
| 02 | ββ | Solution |
| 03 | ||
| 04 | ||
| 05 | ||
| 06 | ||
| 07 | ||
| 08 | ||
| 09 | ||
| 10 | ||
| 11 | ||
| 12 | ||
| 13 | ||
| 14 | ||
| 15 | ||
| 16 | ||
| 17 | ||
| 18 | ||
| 19 | ||
| 20 | ||
| 21 | ||
| 22 | ||
| 23 | ||
| 24 | ||
| 25 |
| Milestone | Stars Earned | Status |
|---|---|---|
| 1-10 Stars | 4/10 | π© On Track |
| 11-20 Stars | 0/10 | π¦ Not Started |
| Full Completion | 4/50 | β¬ |
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:
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 lockfileThe 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!
Before you start, install the required dependencies:
pip install -r requirements.txtRun the CLI by executing:
python -m elf.cli.main <command> [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.
Set up a new folder for a day, complete with templates and input files:
python -m elf.cli.main create-day <year> <day> --output-dir <directory>Example:
python -m elf.cli.main create-day 2016 5Fetch your personalized input for a day:
python -m elf.cli.main fetch-input <year> <day>Example:
python -m elf.cli.main fetch-input 2016 5Run your solution for a specific day and part:
python -m elf.cli.main run <year> <day> --part <1|2|both>Examples:
python -m elf.cli.main run 2016 4 --part 1
python -m elf.cli.main run 2016 4 --part bothRun tests using test_input.txt and expected_output.txt:
python -m elf.cli.main test <year> <day>Example:
python -m elf.cli.main test 2016 4Submit your solution directly to Advent of Code:
python -m elf.cli.main submit <year> <day> <part> <answer>Example:
python -m elf.cli.main submit 2016 4 1 12345To fetch inputs and submit answers, you'll need your Advent of Code session token:
- Log in to Advent of Code and copy your session token from the browser cookies.
- Save it as an environment variable:
export AOC_SESSION_COOKIE='your_session_token_here'
Note: Keep your token secret to prevent unauthorized access.
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:
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! π