Skip to content

princemuel/advent-of-code

Repository files navigation

Advent of Code

This repository contains solutions for Advent of Code, written in Rust and organized per year. A custom CLI tool, aocctl, automates day creation, template selection, input downloading, running, and submissions.

Warning

This repository contains reckless amounts of premature optimizations, (and the not-so optimizations) and consequentially may be occassionally (fine, frequently πŸ˜‰) overly verbose than any reasonable human would willingly write. This is not a cry for help. That's just me exploring how far I can push boundaries with Rust.

I do try to implement the algorithms in a simpler form first, but they are in a private repo, so you're just gonna take my word for it. (like the wizard who said "I totally tested this spell")

What you’ll find here is the after version, where I poke at Rust’s type system with a stick, try unnecessary abstractions, add micro-optimizations no one asked for, and then refuse to delete any of it just because "it might be useful later." Yep, it's my very own Advent of Fun

Project Structure

crates/aoc[year]/
β”œβ”€β”€ Cargo.toml
└── src/
    β”œβ”€β”€ lib.rs          # Shared utilities
    └── bin/
        β”œβ”€β”€ d01.rs      # Day 1 solution
        β”œβ”€β”€ d02.rs      # Day 2 solution
        └── ...

Additional generated folders:

inputs/[year]/    # Downloaded puzzle inputs
answers/[year]/   # Submission records

Prerequisites

 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install just

Quick Start

Setup the AoC credentials

Find your session token for the AoC. You'll need to visit adventofcode.com. Open the devtools of your browser, then:

  • Firefox: "Storage" tab, "Cookies" folder, and copy the "Value" field of the "session" cookie.
  • Google Chrome / Chromium: "Application" tab, "Cookies" folder, and copy the "Value" field of the "session" cookie.

Then store the session cookie in any of these locations:

  • SESSION variable in .env
  • in a .session file in the working dir
  • at $HOME/.config/aoc/.session
  • env var SESSION on the command line

Optional: Install the aocctl cli tool

To have more control and access to more options, you may decide to install the cli tool.

just install

This lets you run the tool directly via its name aocctl instead of prepending cargo run everytime.

Initialize the year

just init 2025
# or
aocctl init 2025

Scaffold a new day

just new 1
# or with a specific template:
aocctl new 1 --template fast

Download input & solve

just solve 1

Available Commands

Build & Test

  • just build β€” Build workspace
  • just test β€” Run all tests
  • just release β€” Build optimized binaries

Run Solutions

  • just run-day 1 puzzle β€” Run day 1 with puzzle input
  • just run β€” Run latest day
  • just solve 1 β€” Download, run, and optionally submit

Advent of Code Integration

  • just input 1 β€” Download input
  • just solve 1 β€” Execute and submit
  • just open 1 β€” Open problem in browser
  • just templates β€” List templates

Development

  • just watch 1 β€” Auto rebuild
  • just lint β€” Clippy + fmt checks
  • just fmt β€” Format code

Template System

Templates define the structure of generated day solutions.

Template Description
minimal Simple, small, stdin-based
buffered Efficient file/stdin input via BufReader
streaming Iterator-based, no full allocation
fast Zero-copy &str parsing

List available templates:

aocctl list-templates

Example:

aocctl new 5 --template streaming

Daily Workflow

just new 7
just input 7
just run-day 7 puzzle
just solve 7

Dry-run submission:

aocctl solve 7 --dry-run

Shared Utilities

use aoc2025::*;

fn solve(input: &str) {
    let lines = lines(input);
    let nums = parse_numbers(input);
    // grid helpers, coordinate math, iter utils, etc.
}

Troubleshooting

Missing session token

echo "<your_cookie>" > .session

Input not downloaded

just input <day>

File doesn’t exist

aocctl new <day>

Performance issues

Use streaming or fast template:

aocctl new <day> --template fast

Contributing

PRs improving templates, utilities, workflow, or documentation are welcome.

License

MIT

Releases

No releases published

Packages

No packages published