MCPcopy Index your code
hub / github.com/ericwburden/advent_of_code_2022

github.com/ericwburden/advent_of_code_2022 @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
720 symbols 1,500 edges 108 files 340 documented · 47%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Eric's Advent of Code 2022 Solutions

The Blog

For the last two years, I've blogged my approaches to the Advent of Code puzzles on my personal site. Assuming I hold true to form, each blog post will include code and commentary on my thinking behind the approach, my thoughts about the puzzles, and vain attempts at wit.

Project Structure

This year, I'm using Rust! I solved 2019's puzzles in Rust after the fact (it's how I learned Rust to begin with), but this year I'll solve each day in Rust first. I've set up folders for each day's code and input files like so:

<project root>
├─benches
│ └─all_days.rs
├─input
│ └─XX
│   ├─input.txt
│   └─test.txt
├─src
│ ├─dayXX
│ │ ├─input.rs
│ │ ├─mod.rs
│ │ ├─part1.rs
│ │ └─part2.rs
│ ├─bin.rs
│ └─lib.rs
├─Cargo.toml
└─README.md

There are a few organizational notes to point out here:

  • The mod.rs file for each day defines Input as a type alias for the type the input file will be parsed into, and a convenience function run(_: Part) -> Output that reads in the input and solves for either part one or part two, depending on the variant of Part that is passed and returns the result as an Output (for consistency). This file also contains the tests that cofirm the answer once it has been found.
  • Output is an enum with variants for u32, i32, u64,i64, andString`. This allows the binary to expect the same (printable) type from each day's solution.
  • Input files are being included in each day's input.rs via the include_str!() macro, which means parsing will be on the file contents as one long, newline-separated, string slice. The main entrypoint for input parsing is the read() -> Input function which takes no arguments (relying on the included INPUT constant) and returns the parsed input file.
  • The part1.rs and part2.rs files each contain a solve(_: &Input) -> Output function that takes a reference to the parsed input and returns the solution for that part of that day.

## Usage

Most of the functionality of this project shell is best accessed via cargo (though you can install the project if you really want to).

  • cargo test to run the tests. Full documentation for that command here
  • cargo bench to run the benchmarks. Full documentation for that command here
  • cargo run to run the first day's solutions and print the results. cargo run <number> to run the day's solutions and print the results.

Extension points exported contracts — how you extend this code

Eval (Interface)
Trait for evaluating an Expression in an Environment [2 implementers]
src/day21/part1.rs
RangeContains (Interface)
Trait for determine whether one `AssignmentRange` completely contains another [1 implementers]
src/day04/part1.rs
Execute (Interface)
This is the trait for executing instructions on a `CrateStacks`. Using a trait here so to allow for different functional [1 …
src/day05/part1.rs
GetBounds (Interface)
This trait provides a convenient way to get the bounding box of a HashSet of Cubes [1 implementers]
src/day18/part2.rs
TryIntoShape (Interface)
Trait for converting a character from the input into a `Shape`. I'm using a Trait here so that I can use the same functi [1 …
src/day02/part1.rs
RockLine (Interface)
A trait for a pair of points to implement to produce a list of rocky points in the line from one point to another. [1 …
src/day14/input.rs
Chunk (Interface)
(no doc) [2 implementers]
src/day23/grid.rs
PartialEval (Interface)
This trait is used to evaluate Expressions in an Environment, updating the Environment whenever a variable is evaluated. [2 …
src/day21/part2.rs

Core symbols most depended-on inside this repo

solve
called by 53
src/day13/part1.rs
read
called by 51
src/day13/input.rs
len
called by 32
src/day17/input.rs
is_path
called by 32
src/day22/input.rs
push
called by 19
src/day17/part1.rs
insert
called by 17
src/day03/input.rs
links
called by 15
src/day22/part1.rs
push
called by 14
src/day05/part1.rs

Shape

Function 380
Method 236
Class 69
Enum 22
Interface 13

Languages

Rust100%

Modules by API surface

benches/all_days.rs74 symbols
src/day23/grid.rs47 symbols
src/day22/input.rs28 symbols
src/day19/input.rs26 symbols
src/day07/input.rs22 symbols
src/day21/input.rs18 symbols
src/day24/input.rs17 symbols
src/day05/input.rs16 symbols
src/day11/input.rs15 symbols
src/day17/input.rs13 symbols
src/day16/input.rs13 symbols
src/day15/input.rs13 symbols

For agents

$ claude mcp add advent_of_code_2022 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact