Skip to content

Commit 83718e3

Browse files
committed
docs: add comprehensive READMEs for root and language subdirectories
1 parent e0779a9 commit 83718e3

4 files changed

Lines changed: 261 additions & 3 deletions

File tree

README.md

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,97 @@
1-
Advent of Code collection
1+
# 🎄 Advent of Code Collection
22

3-
## LETSGOO :rocket:
3+
A comprehensive, multi-language collection of [Advent of Code](https://adventofcode.com/) solutions, standardized and optimized for performance and maintainability.
44

5+
## 🚀 Overview
56

7+
This repository contains solutions for various years of Advent of Code, implemented in multiple languages. The project is structured as a monorepo, grouping solutions by language and providing shared utilities and a unified testing interface.
68

7-
this is coming from a workspace
9+
### 📊 Implementation Matrix
10+
11+
| Year | Rust 🦀 | Golang 🐹 | Zig ⚡ | Status |
12+
| :--- | :---: | :---: | :---: | :--- |
13+
| 2015 || - | - | Complete |
14+
| 2017 | - || - | Refactored |
15+
| 2018 || - | - | Complete (Opt.) |
16+
| 2019 ||| - | Migrated from OCaml |
17+
| 2020 ||| - | Standardized |
18+
| 2021 || - || Migrated from C# |
19+
| 2022 || - | - | Complete |
20+
| 2023 || - | - | Migrated from Scala |
21+
| 2024 | - ||| Standardized |
22+
| 2025 || - | - | In Progress |
23+
24+
---
25+
26+
## 🛠 Project Structure
27+
28+
The repository follows a strict language-based organization:
29+
30+
```text
31+
.
32+
├── golang/ # Go projects grouped by year
33+
├── inputs/ # Centralized puzzle inputs (Source of Truth)
34+
├── rust/ # Rust workspace (Cargo-based)
35+
├── zig/ # Zig projects grouped by year
36+
└── justfile # Task runner for all languages
37+
```
38+
39+
### 🗝 Key Features
40+
41+
- **Standardized Architecture**: Every project follows a "Dispatcher" model, where a single entry point runs individual days.
42+
- **Unified Inputs**: All puzzle inputs are consolidated in a root `inputs/` folder, shared across all languages.
43+
- **Smart Test Caching**: Local and CI tests use a SHA-256 hashing strategy via `just` to skip tests that haven't changed.
44+
- **Optimized History**: The repository history is scrubbed of large build artifacts, making it extremely lean (~1.7MB).
45+
- **Fast CI**: GitHub Actions pipeline is optimized with conditional testing and language-specific caching.
46+
47+
---
48+
49+
## 🏎 Getting Started
50+
51+
### Prerequisites
52+
53+
- [Rust](https://www.rust-lang.org/) (stable/nightly)
54+
- [Go](https://go.dev/) (1.22+)
55+
- [Zig](https://ziglang.org/) (0.14.0+)
56+
- [Just](https://github.com/casey/just) (Task runner)
57+
58+
### Running Tests
59+
60+
We use `just` to provide a consistent interface across all languages.
61+
62+
```bash
63+
# Run all tests across all languages (with smart caching)
64+
just test-all
65+
66+
# Run only Rust tests
67+
just test-rust
68+
69+
# Run only Go tests
70+
just test-go
71+
72+
# Run only Zig tests
73+
just test-zig
74+
75+
# Force a full re-run by cleaning the cache
76+
just clean-cache
77+
```
78+
79+
### Adding New Solutions
80+
81+
1. Place your input in `inputs/<year>/<day>/prod.txt`.
82+
2. Follow the standardized template for your chosen language (see language-specific READMEs).
83+
3. Update the language dispatcher (`main.rs`, `main.go`, etc.).
84+
85+
---
86+
87+
## 📜 Documentation by Language
88+
89+
- [Rust Documentation](./rust/README.md)
90+
- [Golang Documentation](./golang/README.md)
91+
- [Zig Documentation](./zig/README.md)
92+
93+
---
94+
95+
## ⚖️ License
96+
97+
MIT © [Mark Kovari](https://github.com/markkovari)

golang/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# 🐹 Golang Advent of Code
2+
3+
This directory contains Go solutions for Advent of Code, structured as independent modules sharing a common utility library.
4+
5+
## 📁 Structure
6+
7+
Each year is a separate module that uses a local `replace` directive to point to the shared `common` library.
8+
9+
- **`common/`**: Shared interface and input resolution logic.
10+
- **`20XX/`**: Year-specific implementations and dispatchers.
11+
12+
## 🚀 Standardized Day Template
13+
14+
Every day is implemented in a separate file (e.g., `day01.go`) within the year directory:
15+
16+
```go
17+
package main
18+
19+
import (
20+
"fmt"
21+
"github.com/markkovari/advent_of_code/golang/common"
22+
)
23+
24+
type DayXX struct{}
25+
26+
func (d DayXX) Part1(input string) string {
27+
return "result"
28+
}
29+
30+
func (d DayXX) Part2(input string) string {
31+
return "result"
32+
}
33+
```
34+
35+
## 🧪 Running Solutions
36+
37+
Go solutions are run through a centralized `main.go` in each year directory.
38+
39+
```bash
40+
# Navigate to the year
41+
cd golang/2024
42+
43+
# Run a specific day
44+
go run . 1
45+
46+
# Run tests
47+
go test ./...
48+
```
49+
50+
## 🛠 Adding a New Year
51+
52+
1. Create a folder: `mkdir -p 20XX`.
53+
2. Initialize module: `go mod init github.com/markkovari/advent_of_code/golang/20XX`.
54+
3. Add `replace` to `go.mod`: `replace github.com/markkovari/advent_of_code/golang/common => ../common`.
55+
4. Create your `dayXX.go` files and a `main.go` dispatcher.

rust/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# 🦀 Rust Advent of Code
2+
3+
This directory contains Rust solutions for Advent of Code, organized as a Cargo workspace.
4+
5+
## 📁 Structure
6+
7+
Each year is a separate crate within the workspace, depending on a shared `common` library.
8+
9+
- **`common/`**: Shared utilities (input handling, geometry, BFS/Dijkstra algorithms).
10+
- **`20XX/`**: Year-specific implementations.
11+
- **`runner/`**: A master CLI tool to run any day from any year.
12+
13+
## 🚀 Standardized Day Template
14+
15+
Every day is implemented as a struct that satisfies the `Solution` trait:
16+
17+
```rust
18+
use anyhow::Result;
19+
use aoc_common::Solution;
20+
21+
pub struct DayXX;
22+
23+
impl Solution for DayXX {
24+
fn year(&self) -> u32 { 2023 }
25+
fn day(&self) -> u32 { XX }
26+
27+
fn part1(&self, input: &str) -> Result<String> {
28+
Ok("result".to_string())
29+
}
30+
31+
fn part2(&self, input: &str) -> Result<String> {
32+
Ok("result".to_string())
33+
}
34+
}
35+
36+
aoc_common::aoc_test!(DayXX);
37+
```
38+
39+
## 🧪 Testing
40+
41+
We use `insta` for snapshot testing and a custom `aoc_test!` macro for regression testing.
42+
43+
### Local Execution
44+
```bash
45+
# Run all tests in the workspace
46+
cargo test
47+
48+
# Run a specific year
49+
cargo test -p aoc-rust-2023
50+
51+
# Run regression tests (including those ignored in CI)
52+
cargo test -- --ignored
53+
```
54+
55+
### CI Environment
56+
In CI, heavy file-reading tests are marked as `#[ignore]` via the `advent_of_code_ci` flag to maintain pipeline speed.
57+
58+
## 🛠 Adding a New Year
59+
60+
1. Create a new folder: `mkdir -p 20XX/src`.
61+
2. Initialize `Cargo.toml` with `aoc-rust-20XX` name and dependency on `../common`.
62+
3. Add the folder to `rust/Cargo.toml` workspace members.
63+
4. Implement your days in `src/dayXX.rs`.
64+
5. Register them in `src/lib.rs` and `src/main.rs`.

zig/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# ⚡ Zig Advent of Code
2+
3+
This directory contains Zig solutions for Advent of Code, optimized for performance and type safety.
4+
5+
## 📁 Structure
6+
7+
Solutions are grouped by year, with each year containing its own `build.zig` and source files.
8+
9+
- **`20XX/`**: Year-specific implementations.
10+
- **`20XX/src/`**: Daily logic.
11+
12+
## 🚀 Standardized Day Template
13+
14+
Every day is implemented in `src/XX/main.zig`:
15+
16+
```zig
17+
const std = @import("std");
18+
19+
pub fn main() !void {
20+
// Runtime execution logic
21+
}
22+
23+
fn part1(input: []const u8) !u32 {
24+
return 0;
25+
}
26+
27+
test "day XX prod" {
28+
const input = @embedFile("../../../inputs/2021/X/prod.txt");
29+
try std.testing.expectEqual(@as(u32, 123), try part1(input));
30+
}
31+
```
32+
33+
## 🧪 Testing
34+
35+
We use Zig's built-in test runner to verify solutions at compile-time using `@embedFile`.
36+
37+
```bash
38+
# Navigate to the year
39+
cd zig/2021
40+
41+
# Run all tests
42+
zig build test
43+
```
44+
45+
## 🛠 Adding a New Year
46+
47+
1. Create a folder: `mkdir -p 20XX/src`.
48+
2. Create a `build.zig` that iterates over days and creates test steps.
49+
3. Implement your days in `src/XX/main.zig`.

0 commit comments

Comments
 (0)