Skip to content

cak/advent-of-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ„ Advent of Code πŸŽ„

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! ✨

πŸ“… Advent of Code 2024 Progress (Goal: 20 Stars ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐)

⭐ Progress: 4/50 ⭐

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

🎯 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:

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:

pip install -r requirements.txt

Commands Overview

Run 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.

Command Details

1. Create a New Day Folder

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 5

2. Fetch Puzzle Input

Fetch your personalized input for a day:

python -m elf.cli.main fetch-input <year> <day>

Example:

python -m elf.cli.main fetch-input 2016 5

3. Run a Solution

Run 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 both

4. Test Your Solution

Run 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 4

5. Submit Your Answer

Submit 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 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 and copy your session token from the browser cookies.
  2. Save it as an environment variable:
    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:

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! πŸŽ…

About

Python solutions for Advent of Code challenges, organized by year.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages