Awesome
🎄 Advent of Code in Deno/TypeScript
Solutions
- deno 2.1.2, windows x86_64, 31.76 GB, Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
- deno 2.1.2, windows x86_64, 31.93 GB, AMD Ryzen 7 5800X3D 8-Core Processor
- deno 2.1.2, windows x86_64, 15.91 GB, AMD Ryzen 5 3600 6-Core Processor
2024 | Part 1 | Part 2 |
---|---|---|
Day 1 | 1ms <sup>2</sup> | 0.8ms <sup>2</sup> |
Day 2 | 1.0ms <sup>2</sup> | 1ms <sup>2</sup> |
Day 3 | 2ms <sup>2</sup> | 2ms <sup>2</sup> |
Day 4 | 3ms <sup>2</sup> | 3ms <sup>2</sup> |
Day 5 | 2ms <sup>2</sup> | 2ms <sup>2</sup> |
Day 6 | 4ms <sup>2</sup> | 6.9s <sup>2</sup> |
Day 7 | 114ms <sup>2</sup> | 8.2s <sup>2</sup> |
Day 8 | 1.0ms <sup>2</sup> | 2ms <sup>2</sup> |
Day 9 | 960ms <sup>2</sup> | 436ms <sup>2</sup> |
Day 10 | 8ms <sup>1</sup> | 7ms <sup>1</sup> |
Day 11 | 2ms <sup>2</sup> | 38ms <sup>2</sup> |
Day 12 | 31ms <sup>1</sup> | 37ms <sup>1</sup> |
Day 13 | 0.8ms <sup>2</sup> | 0.7ms <sup>2</sup> |
Day 14 | 0.7ms <sup>2</sup> | 198ms <sup>2</sup> |
Day 15 | 2ms <sup>2</sup> | 6ms <sup>2</sup> |
Day 16 | 154ms <sup>1</sup> | 725ms <sup>1</sup> |
Day 17 | 0.2ms <sup>3</sup> | 0.2ms <sup>3</sup> |
Day 18 | 4ms <sup>2</sup> | 15ms <sup>2</sup> |
Day 19 | 20ms <sup>1</sup> | 46ms <sup>1</sup> |
Day 20 | 135ms <sup>3</sup> | 285ms <sup>3</sup> |
2023 | Part 1 | Part 2 |
---|---|---|
Day 1 | 0.8ms <sup>2</sup> | 22ms <sup>2</sup> |
Day 2 | 0.8ms <sup>2</sup> | 0.8ms <sup>2</sup> |
Day 3 | 2ms <sup>2</sup> | 1ms <sup>2</sup> |
Day 4 | 1ms <sup>2</sup> | 112ms <sup>2</sup> |
Day 5 | 0.8ms <sup>2</sup> | 14.5s <sup>2</sup> |
Generated at Sat, 21 Dec 2024 21:36:31 GMT
Prerequisites
Setup
git clone
this repositorycd
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 puzzleyear
defaults to the year of the latest AoCpart
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.