This repository contains solutions and a runner for Advent of Code, built with Bun and TypeScript.
- Bun (latest version recommended)
- Clone the repository.
- Install dependencies:
bun install
Create a .env file in the root directory to store your session cookie. This is required for downloading inputs and puzzle descriptions.
AOC_SESSION=your_session_cookie_hereThe project includes several scripts to help manage and run your solutions. The CLI defaults to the current day and year if options are omitted.
Sets up the directory structure for a new day, creates solution files from templates, and downloads the input and puzzle description.
bun run scaffold [-d|--day <day>] [-y|--year <year>] [-f|--force]Options:
-d, --day <day>: Day number (1-25), defaults to current day-y, --year <year>: Year (e.g., 2024), defaults to current year-f, --force: Force re-download even if files exist
Example:
bun run scaffold -d 1 -y 2024Test against sample input:
Runs the solution using sample.txt.
bun run try [-d|--day <day>] [-y|--year <year>]Run against real input:
Runs the solution using input.txt and displays execution time.
bun run attempt [-d|--day <day>] [-y|--year <year>]Downloads the puzzle description to puzzle.md if it doesn't already exist.
bun run read [-d|--day <day>] [-y|--year <year>] [-f|--force]Re-downloads the puzzle description (useful after solving part 1 to see part 2).
bun run refresh [-d|--day <day>] [-y|--year <year>]Run all tests using Vitest:
bun run checkRun tests in watch mode:
bun run watchsrc/: Source code for the CLI and utilitiessrc/commands/: Individual command implementationssrc/utils/: Utility functions for CLI helpers, downloading, testing, etc.src/templates/: Eta templates (.etafiles) for generating new solution runners and tests
aoc/[year]/[day]/: Generated solution files (runner, tests, input, puzzle.md, etc.)
Templates use Eta syntax. Variables are accessed via it (e.g., <%= it.year %>, <%= it.day %>). To customize templates, edit the .eta files in src/templates/.
MIT