dylanlangston/AOC2025
Advent of a code 2025 in Zig
My solutions for Advent of Code 2025, written in Zig.
As an added challenge to myself, I aim to implement each solution with the following constraints:
This project includes a Dev Container for a pre-configured development environment. Open the project in VS Code and select "Reopen in Container" to get started instantly with Zig and all dependencies ready.
# Build the project
zig build
# Run all days
zig build run
# Run a specific day (e.g., day 2)
zig build run -- 2
# Run tests
zig build test
src/
├── main.zig # CLI entry point
├── root.zig # Shared utilities (solutions, obfuscation, lookup tables)
├── day_discovery.zig # Build-time day auto-discovery
├── embed_input.zig # Build-time input file embedding
├── days/ # Daily solution files
│ ├── one.zig
│ ├── two.zig
│ └── ...
└── inputs/ # Puzzle input files
├── one.txt
├── two.txt
└── ...
As part of the build we auto-discover and register daily solutions and inputs:
src/day_discovery.zig): Scans src/days/ for .zig files and generates a DayLocator module with all solutions registered automatically.src/embed_input.zig): Scans src/inputs/ for .txt files and embeds them directly into the binary, making puzzle inputs available at runtime without external file access.Solution_Part_One and Solution_Part_Two functions that return a numeric or string result.src/days/<day_name>.zig (e.g., four.zig)src/inputs/<day_name>.txt (e.g., four.txt)const std = @import("std");
const inputs = @import("input").Input;
const input = inputs.<day_name>.data();
pub fn Solution_Part_One() !u64 {
// Your solution here
return 0;
}
pub fn Solution_Part_Two() !u64 {
// Your solution here
return 0;
}
Tests are automatically discovered alongside solutions. Add test blocks in your day files and they'll be included when running zig build test.
Each day typically includes multiple types of tests:
// Test with example data from the puzzle description
test "Example Pattern Part 1" {
const result = try solvePart1(exampleInput);
try std.testing.expectEqual(42, result);
}
// Verify the actual solution using obfuscated expected values
test "Solution Part One" {
const result = try Solution_Part_One();
try std.testing.expectEqual(solutions.DayOne_PartOne.value(), result);
}
When you solve a new day, add the obfuscated answer to src/root.zig:
zig build run to get the obfuscated value from the output:info: Solution to Day 4 🐦🐦🐦🐦
info: Part 1: 12345 (obf: 54321)
info: Part 2: 67890 (obf: 98765)
DayFour_PartOne, DayFour_PartTwo)value() switch:.DayFour => switch (part) {
.PartOne => obf(54321),
.PartTwo => obf(98765),
},