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, 15.91 GB, AMD Ryzen 5 3600 6-Core Processor
  2. deno 2.1.2, windows x86_64, 31.76 GB, Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
  3. 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) 3 ⭐ (0.8ms) 3
Day 2 ⭐ (1.0ms) 3 ⭐ (1ms) 3
Day 3 ⭐ (2ms) 3 ⭐ (2ms) 3
Day 4 ⭐ (3ms) 3 ⭐ (3ms) 3
Day 5 ⭐ (2ms) 3 ⭐ (2ms) 3
Day 6 ⭐ (4ms) 3 ⭐ (6.9s) 3
Day 7 ⭐ (114ms) 3 ⭐ (8.2s) 3
Day 8 ⭐ (1.0ms) 3 ⭐ (2ms) 3
Day 9 ⭐ (960ms) 3 ⭐ (436ms) 3
Day 10 ⭐ (8ms) 2 ⭐ (7ms) 2
Day 11 ⭐ (2ms) 3 ⭐ (38ms) 3
Day 12 ⭐ (31ms) 2 ⭐ (37ms) 2
Day 13 ⭐ (0.8ms) 3 ⭐ (0.7ms) 3
Day 14 ⭐ (0.7ms) 3 ⭐ (198ms) 3
Day 15 ⭐ (2ms) 3 ⭐ (6ms) 3
Day 16 ⭐ (154ms) 2 ⭐ (725ms) 2
Day 17 ⭐ (0.2ms) 1 ⭐ (0.2ms) 1
Day 18 ⭐ (4ms) 3 ⭐ (15ms) 3
Day 19 ⭐ (20ms) 2 ⭐ (46ms) 2
Day 20 ⭐ (135ms) 1 ⭐ (285ms) 1
Day 21
Day 22 ⭐ (74ms) 1 ⭐ (1.5s) 1
Day 23 ⭐ (4ms) 1 ⭐ (10ms) 1
Day 24 ⭐ (1ms) 1
Day 25 ⭐ (3ms) 1
2023 Part 1 Part 2
Day 1 ⭐ (0.8ms) 3 ⭐ (22ms) 3
Day 2 ⭐ (0.8ms) 3 ⭐ (0.8ms) 3
Day 3 ⭐ (2ms) 3 ⭐ (1ms) 3
Day 4 ⭐ (1ms) 3 ⭐ (112ms) 3
Day 5 ⭐ (0.8ms) 3 ⭐ (14.5s) 3

Generate README

Generated at Wed, 25 Dec 2024 14:11:54 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.