This repository contains solutions and visualizations for Advent of Code 2023 event implemented in TypeScript (mostly Node.js + browser-based visualizations).
The only requirement the build and run the code is Node.js v20.x or later.
To begin, clone the repository and run the following command to install dependencies:
npm ci
The you can use the following commands:
Command | Description |
---|---|
npm run node-start -- ./src/puzzle{NN}.ts |
Run solutions for day NN |
npm run node-build |
Test if everything compiles without errors |
npm run browser-serve |
Run local web server with visualizations for some puzzles |
npm run browser-build |
Build static resources to deploy visualizations on e.g. GitHub pages |
Each solution expects the input data at input/puzzleNN.txt
from the repository root. If needed, test data can be provided via input/puzzleNN_test.txt
and changed in the source to use a different file.
Some solutions will write additional output for debugging or simple visualization means into output/puzzleNN*
files (the directory will be crated if necessary).
The repository contains launch configuration for Visual Studio Code debugger at .vscode/lunch.json
such that each puzzle solution can be launched separately with debugger attached just by opening the solution source and selecting Run > Start Debugging
or pressing F5
(with default keybindings).
Day 01 solution
Spoiler for day 01
Day 1: Trebuchet?!
Both base and advanced parts are done via RegExp-based solution. The trick for matching from the end of a string is to 1. reverse the string, 2. reverse the RegExp itself (including the digit words, e.g. two
becomes owt
after reverse).