Skip to content

mabenj/aoc-deno-ts

Repository files navigation

🎄 Advent of Code in Deno/TypeScript

Solutions

  1. deno 2.1.2, windows x86_64, 31.76 GB, Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
  2. deno 2.1.2, windows x86_64, 31.93 GB, AMD Ryzen 7 5800X3D 8-Core Processor
2024 Part 1 Part 2
Day 1 1ms 2 0.8ms 2
Day 2 1.0ms 2 1ms 2
Day 3 2ms 2 2ms 2
Day 4 3ms 2 3ms 2
Day 5 2ms 2 2ms 2
Day 6 4ms 2 6.9s 2
Day 7 114ms 2 8.2s 2
Day 8 1.0ms 2 2ms 2
Day 9 960ms 2 436ms 2
Day 10 8ms 1 7ms 1
Day 11 2ms 2 38ms 2
Day 12 31ms 1 37ms 1
Day 13 0.8ms 2 0.7ms 2
Day 14 0.7ms 2 198ms 2
Day 15 2ms 2 6ms 2
2023 Part 1 Part 2
Day 1 0.8ms 2 22ms 2
Day 2 0.8ms 2 0.8ms 2
Day 3 2ms 2 1ms 2
Day 4 1ms 2 112ms 2
Day 5 0.8ms 2 14.5s 2

Generate README

Generated at Sun, 15 Dec 2024 22:18:16 GMT

Prerequisites

Setup

  1. git clone this repository
  2. cd into the repository

❗ Note: to start from scratch without my solutions, delete all the puzzle directories and the solver-factory.ts file in the lib directory.

Project Structure

📦
├─ lib/
│  ├─ yyDd/                       # puzzle directory for year `yy` and day `d`
│  │  ├─ input.txt                # input for the puzzle (git ignored)
│  │  ├─ puzzle.md                # problem description (git ignored)
│  │  └─ solver.ts                # solution for the puzzle
│  ├─ commands/
│  │  ├─ init.ts                  # command to scaffold a new puzzle directory
│  │  └─ solve.ts                 # command to solve a puzzle
│  ├─ tests/
│  │  ├─ main_test.ts             # unit tests for all the solvers
│  │  └─ main_test_answers.json   # correct answers for the puzzles
│  ├─ common.ts                   # common utility code
│  └─ solver-factory.ts           # factory for creating solvers
├─ deno.json                      # Deno configuration
└─ main.ts                        # entry point for the program

Usage

Solve the puzzle for the given year, day and part:

deno run solve [-d, --day <day>] [-p, --part <1 | 2>] [-y, --year <year>]

Initialize and scaffold a new puzzle directory into the lib directory:

deno run init [-d, --day <day>] [-y, --year <year>]

Defaults:

  • day defaults to the day of the latest puzzle
  • year defaults to the year of the latest AoC
  • part defaults to 1

❗ Note: to use the init command to automatically scaffold a new puzzle directory and to fetch your input and problem description, you will need to set the AOC_SESSION environment variable to your Advent of Code session cookie. You can achieve this by creating a .env file with AOC_SESSION=<session cookie> in the root of your project (see .env.example). This same variable is also used to submit answers after solving a puzzle.

Testing

deno test will run all the solvers and test their output

❗ Note: the tests expects the lib/tests/main_test-answers.json file to contain the correct answers for the puzzles.