Skip to content

zacowan/aoc-template-typescript

Repository files navigation

🎄 Advent of Code TypeScript Template

Note

This repo is inspired by Felix Spöttel's excellent Rust template that I used in 2023 - you can find that here.

Template for developing solutions for Advent of Code.

Setup

  1. Install Fast Node Manager or Node Version Manager.
  2. Use the right version of Node:
fnm use
# or
nvm use
  1. Install pnpm.
  2. Install required dependencies:
pnpm i
  1. ✅ You're ready to go!

Usage

This project comes with scripts to make problem-solving fun.

Scaffold a day

# example: `pnpm scaffold 1`
pnpm scaffold <day>

# output:
# Created empty example file "data/examples/01.txt"
# Created empty input file "data/inputs/01.txt"
# Created test file "src/solutions/01/01.test.ts"
# Created solution file "src/solutions/01/01.ts"
# ---
# 🎄 Type `pnpm solve 1` to run your solution.

Individual solutions live in the ./src/solutions/ directory as separate files. Inputs and examples live in the the ./data directory.

Every solution has tests referencing its example file in ./data/examples. Use these tests to develop and debug your solutions against the example input.

Run solutions for a day

# example: `pnpm solve 01`
pnpm solve <day>

# output:
# Part One: 42
# Part Two: 42

The solve command runs your solution against real puzzle inputs from the ./data/inputs directory.

Run all tests

pnpm test

This just runs vitest under-the-hood and supports all of the same CLI options at the vitest CLI.

Lint code

pnpm lint

Typecheck code

pnpm typecheck