An open API service indexing awesome lists of open source software.

https://github.com/mabenj/aoc-deno-ts

Advent of Code - Deno/TypeScript
https://github.com/mabenj/aoc-deno-ts

aoc-2024-in-deno aoc-2024-in-typescript deno typescript

Last synced: about 2 months ago
JSON representation

Advent of Code - Deno/TypeScript

Awesome Lists containing this project

README

        

# 🎄 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](/lib/24D1/solver.ts) | ⭐ (1ms) 3 | ⭐ (0.8ms) 3 |
| [Day 2](/lib/24D2/solver.ts) | ⭐ (1.0ms) 3 | ⭐ (1ms) 3 |
| [Day 3](/lib/24D3/solver.ts) | ⭐ (2ms) 3 | ⭐ (2ms) 3 |
| [Day 4](/lib/24D4/solver.ts) | ⭐ (3ms) 3 | ⭐ (3ms) 3 |
| [Day 5](/lib/24D5/solver.ts) | ⭐ (2ms) 3 | ⭐ (2ms) 3 |
| [Day 6](/lib/24D6/solver.ts) | ⭐ (4ms) 3 | ⭐ (6.9s) 3 |
| [Day 7](/lib/24D7/solver.ts) | ⭐ (114ms) 3 | ⭐ (8.2s) 3 |
| [Day 8](/lib/24D8/solver.ts) | ⭐ (1.0ms) 3 | ⭐ (2ms) 3 |
| [Day 9](/lib/24D9/solver.ts) | ⭐ (960ms) 3 | ⭐ (436ms) 3 |
| [Day 10](/lib/24D10/solver.ts) | ⭐ (8ms) 2 | ⭐ (7ms) 2 |
| [Day 11](/lib/24D11/solver.ts) | ⭐ (2ms) 3 | ⭐ (38ms) 3 |
| [Day 12](/lib/24D12/solver.ts) | ⭐ (31ms) 2 | ⭐ (37ms) 2 |
| [Day 13](/lib/24D13/solver.ts) | ⭐ (0.8ms) 3 | ⭐ (0.7ms) 3 |
| [Day 14](/lib/24D14/solver.ts) | ⭐ (0.7ms) 3 | ⭐ (198ms) 3 |
| [Day 15](/lib/24D15/solver.ts) | ⭐ (2ms) 3 | ⭐ (6ms) 3 |
| [Day 16](/lib/24D16/solver.ts) | ⭐ (154ms) 2 | ⭐ (725ms) 2 |
| [Day 17](/lib/24D17/solver.ts) | ⭐ (0.2ms) 1 | ⭐ (0.2ms) 1 |
| [Day 18](/lib/24D18/solver.ts) | ⭐ (4ms) 3 | ⭐ (15ms) 3 |
| [Day 19](/lib/24D19/solver.ts) | ⭐ (20ms) 2 | ⭐ (46ms) 2 |
| [Day 20](/lib/24D20/solver.ts) | ⭐ (135ms) 1 | ⭐ (285ms) 1 |
| [Day 21](/lib/24D21/solver.ts) | ❌ | ❌ |
| [Day 22](/lib/24D22/solver.ts) | ⭐ (74ms) 1 | ⭐ (1.5s) 1 |
| [Day 23](/lib/24D23/solver.ts) | ⭐ (4ms) 1 | ⭐ (10ms) 1 |
| [Day 24](/lib/24D24/solver.ts) | ⭐ (1ms) 1 | ❌ |
| [Day 25](/lib/24D25/solver.ts) | ⭐ (3ms) 1 | ❌ |

| 2023 | Part 1 | Part 2 |
| :--- | :--- | :--- |
| [Day 1](/lib/23D1/solver.ts) | ⭐ (0.8ms) 3 | ⭐ (22ms) 3 |
| [Day 2](/lib/23D2/solver.ts) | ⭐ (0.8ms) 3 | ⭐ (0.8ms) 3 |
| [Day 3](/lib/23D3/solver.ts) | ⭐ (2ms) 3 | ⭐ (1ms) 3 |
| [Day 4](/lib/23D4/solver.ts) | ⭐ (1ms) 3 | ⭐ (112ms) 3 |
| [Day 5](/lib/23D5/solver.ts) | ⭐ (0.8ms) 3 | ⭐ (14.5s) 3 |

[![Generate README](https://github.com/mabenj/aoc-deno-ts/actions/workflows/generate-readme.yml/badge.svg)](https://github.com/mabenj/aoc-deno-ts/actions/workflows/generate-readme.yml)
> Generated at Wed, 25 Dec 2024 14:11:54 GMT

## Prerequisites

- [Deno](https://deno.land/)

## 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 ] [-p, --part <1 | 2>] [-y, --year ]
```

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

```
deno run init [-d, --day ] [-y, --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=` 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.