Home

Awesome

🎄 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
  3. deno 2.1.2, windows x86_64, 15.91 GB, AMD Ryzen 5 3600 6-Core Processor
2024Part 1Part 2
Day 11ms <sup>2</sup>0.8ms <sup>2</sup>
Day 21.0ms <sup>2</sup>1ms <sup>2</sup>
Day 32ms <sup>2</sup>2ms <sup>2</sup>
Day 43ms <sup>2</sup>3ms <sup>2</sup>
Day 52ms <sup>2</sup>2ms <sup>2</sup>
Day 64ms <sup>2</sup>6.9s <sup>2</sup>
Day 7114ms <sup>2</sup>8.2s <sup>2</sup>
Day 81.0ms <sup>2</sup>2ms <sup>2</sup>
Day 9960ms <sup>2</sup>436ms <sup>2</sup>
Day 108ms <sup>1</sup>7ms <sup>1</sup>
Day 112ms <sup>2</sup>38ms <sup>2</sup>
Day 1231ms <sup>1</sup>37ms <sup>1</sup>
Day 130.8ms <sup>2</sup>0.7ms <sup>2</sup>
Day 140.7ms <sup>2</sup>198ms <sup>2</sup>
Day 152ms <sup>2</sup>6ms <sup>2</sup>
Day 16154ms <sup>1</sup>725ms <sup>1</sup>
Day 170.2ms <sup>3</sup>0.2ms <sup>3</sup>
Day 184ms <sup>2</sup>15ms <sup>2</sup>
Day 1920ms <sup>1</sup>46ms <sup>1</sup>
Day 20135ms <sup>3</sup>285ms <sup>3</sup>
2023Part 1Part 2
Day 10.8ms <sup>2</sup>22ms <sup>2</sup>
Day 20.8ms <sup>2</sup>0.8ms <sup>2</sup>
Day 32ms <sup>2</sup>1ms <sup>2</sup>
Day 41ms <sup>2</sup>112ms <sup>2</sup>
Day 50.8ms <sup>2</sup>14.5s <sup>2</sup>

Generate README

Generated at Sat, 21 Dec 2024 21:36:31 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:

âť— 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.