Welcome to our team's Advent of Code solutions! This repository is configured as a TypeScript + Bun monorepo, designed to let us code together, compare solutions, and race for the fastest execution times.
This repo uses Bun for lightning-fast installs and running.
# MacOS / Linux / WSL
curl -fsSL https://bun.sh/install | bash
# Windows (PowerShell)
powershell -c "irm bun.sh/install.ps1 | iex"Clone the repo and install dependencies:
git clone <repo-url>
cd aoc-team
bun installYou need to authenticate with Advent of Code to fetch your puzzle inputs automatically.
-
Copy the example env file:
cp .env.example .env
-
Get your Session Cookie:
- Log in to Advent of Code.
- Right-click anywhere on the page and select Inspect.
- Go to the Application tab (Chrome) or Storage tab (Firefox).
- Expand Cookies in the sidebar and click on
https://adventofcode.com. - Copy the value of the
sessioncookie.
-
Edit
.env:- Paste the cookie into
AOC_SESSION. - Set
AOC_USERto your preferred username (e.g.,alice). This will be your folder name insrc/.
- Paste the cookie into
Generate the boilerplate and download your puzzle input in one go:
bun run gen <day> [year]
# Example: bun run gen 1 2024- Day folders are always zero-padded (
day01,day02, ...). scripts/scaffold.tsrefuses to overwrite an existing folder, createsindex.ts,index.test.ts, andinput.txt, then populates the input via yourAOC_SESSION.- The default year is the current calendar year; pass an explicit year to backfill older puzzles.
Use the fast watch runner that wraps bun test --watch with smart filtering from scripts/dev.ts:
| Scope | Command | Notes |
|---|---|---|
| Watch everything I have | bun run dev |
Scans src/<AOC_USER> across all years. |
| Watch a single day | bun run dev 7 |
Accepts 7 or 07; discovers all matching years automatically. |
If AOC_USER is missing the script exits early, so double-check your .env.
We now rely directly on the native Bun test runner (bun test). It understands globs and directories, so you can mix and match filters as needed:
| Scenario | Command |
|---|---|
| Run my entire workspace | bun test src/$AOC_USER |
| Run my Day 05 once | bun test src/$AOC_USER/**/day05/** |
| Watch my Day 05 | bun test --watch src/$AOC_USER/**/day05/** |
| Run Day 05 for everyone | bun test **/day05/** |
| Run everything for everyone | bun test |
- Append
--watchto keepbun testhot-reloading. - Filters accept either padded (
05) or non-padded (5) folder names; stick with the padded convention to match the scaffold. - CI uses the same
bun testcommand via thetestnpm script.
-
Paste the example input into
index.test.ts(the template already contains the right hooks). -
Iterate until the Example test passes in watch mode.
-
Check the Real Input test output to grab your answers.
-
Submit the numbers to Advent of Code, then persist them inside the
realobject so future runs assert against the truth:const real = { input: await readFile(new URL('./input.txt', import.meta.url), 'utf8'), solution1: '12345', solution2: '67890' }
The scaffolded tests already compare
part1/part2againstreal.solution1/solution2, so once you update those strings the suite will fail anytime you regress.
bun run bench <day> [year]
# Example: bun run bench 5scripts/bench.ts performs three phases:
- Host verification – runs
bun test src/<AOC_USER>/<year>/dayXXto make sure your solution is green before trusting it. - Validation – loads every other teammate’s implementation for that day/year and confirms their answers match yours.
- Benchmarking – uses
mitatato print p50/p75/p99 timings with your solution as the baseline.
Only solutions that match your answers enter the race, and disagreements are surfaced with a consensus warning.
src/
├── utils/ # Shared helpers (Graph algos, Grids, Math)
├── alice/ # Alice's solutions
├── bob/ # Bob's solutions
└── ...
Feel free to add shared utilities to src/utils/ if you write a helper that the team could use!
| Command | Description |
|---|---|
bun run gen <day> [year] |
Scaffold + download input for the day. |
bun run dev [day] |
Watch mode for your workspace (optional day filter). |
bun test [path/glob] |
Native Bun test runner (use globs for filtering + --watch). |
bun run bench <day> [year] |
Validate and benchmark every implementation. |
bun run format |
Format everything with Prettier. |