These are my Advent of Code solutions for years 2017 to 2024, written in TypeScript as part of the Recurse Center's Advent of Code group.
In most cases, I optimized for solving the problem quickly, so some of these solutions are... messy. But they (mostly) work! π
I've added all problems I attempt, whether or not I completed them.
| Year | Progress |
|---|---|
| 2017 | |
| 2019 | |
| 2023 | |
| 2024 |
- TypeScript solutions with strong typing
- Comprehensive utility library for common AoC patterns (grids, graphs, pathfinding, etc.)
- Jest test suite with examples from problem descriptions
- Solution runner for easy execution
- Template generator for quickly starting new days
# Clone the repository
git clone https://github.com/Nostromos/AdventOfCode
cd AdventOfCode# Install dependencies
npm install
# Run a specific day's solution
npm run solve -- <year> <day># Example: Run 2024 Day 1
npm run solve -- 2024 1
# Generate files for a new day
npm run new-solution -- <year> <day># Example: Create template for 2024 Day 25
npm run new-solution -- 2024 25
This creates:
solutions/<year>/<day>/solution.ts- Solution file with boilerplatesolutions/<year>/<day>/solution.test.ts- Test file templatesolutions/<year>/<day>/Input.txt- Empty input filesolutions/<year>/<day>/Problem.md- Problem description placeholder
# Run all tests
npm run jest# Run tests for a specific day
npm run jest 2024/1
# Run tests with coverage
npm run jest -- --coverage
solutions/ # All solutions organized by year and day
ββ 2017/
β ββ 1/
β β ββ Input.txt # Puzzle input (gitignored)
β β ββ Problem.md # Problem description (gitignored)
β β ββ solution.ts # Solution implementation
β β ββ solution.test.ts # Test cases from examples
β ββ 2/
β ββ .../
ββ 2019/
ββ 2023/
ββ 2024/
utils/ # Reusable utilities for AoC problems
ββ index.ts # Main exports and input loading
ββ parsing.ts # Input parsing utilities
ββ grid.ts # 2D grid operations
ββ algorithms.ts # Graph algorithms (BFS, DFS, Dijkstra, etc.)
ββ math.ts # Mathematical utilities
ββ structures.ts # Data structures (PriorityQueue, UnionFind, etc.)
ββ debug.ts # Debugging and performance tools
ββ Template/ # Templates for new solutions
docs/ # Documentation and notes
The utils/ directory contains a comprehensive library of utilities commonly needed for AoC:
- Parsing: Line splitting, number extraction, grid parsing, grouped input
- Grid Operations: 2D array manipulation, neighbors, rotation, pathfinding
- Algorithms: BFS, DFS, Dijkstra, A*, topological sort, cycle detection
- Math: GCD/LCM, prime numbers, combinatorics, modular arithmetic
- Data Structures: Priority queue, union-find, trie, deque
- Debugging: Benchmarking, memoization, grid visualization
See docs/UTILITIES.md for detailed documentation.
Due to Advent of Code's policy, puzzle inputs and problem descriptions are not included in this repository. You'll need to:
- Get your puzzle input from adventofcode.com
- Paste it in the
Input.txtfile in the appropriate day's directory - Optionally, save the problem description in the
Problem.mdfile under the same directory.
These files are .gitignoreed to respect the author's wishes and IP. The only way to have fun is solving these yourself with your own input!
- Node.js 18+
- npm or pnpm
- TypeScript configuration in
tsconfig.json - Jest configuration in
jest.config.ts - Path aliases configured for
@/and@/utils
- Solutions prioritize getting the right answer quickly over code elegance
- Some solutions may contain exploratory code or alternative approaches
- The utility library has evolved over time, so not all solutions use the latest utilities
- Performance timings are included in solution output
Thanks to Claire, Bret, and Florian for the meetings, patience, and good nature.
Big ups to Eric Wastl for creating these.
See the LICENSE file for more information.
