Skip to content

AlexeyMz/advent-of-code-2023

Repository files navigation

Solutions + visualizations for Advent of Code 2023

This repository contains solutions and visualizations for Advent of Code 2023 event implemented in TypeScript (mostly Node.js + browser-based visualizations).

Running the code

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

Expected input/output locations

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).

Debugger configuration for VSCode

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).

Solution comments for each day

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).

Day 02 solution

Day 03 solution

Day 04 solution

Day 05 solution

Day 06 solution

Day 07 solution

Day 08 solution

Day 09 solution

Day 10 solution

Day 11 solution

Day 12 solution

Day 13 solution

About

Solutions for Advent of Code 2023 in TypeScript

Topics

Resources

Stars

Watchers

Forks

Languages