Skip to content

Commit 135162d

Browse files
authored
Merge pull request #6 from weaponsforge/dev
v1.1.0
2 parents b6df5c7 + 7d772b7 commit 135162d

File tree

15 files changed

+1363
-12
lines changed

15 files changed

+1363
-12
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Weapons Forge
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,82 @@
1-
## adventofcode
1+
## adventofcode
22

3-
Solutions for [Advent of Code](https://adventofcode.com/) event puzzles.
3+
This repository contains solutions and a local development environment for the [Advent of Code](https://adventofcode.com/) event puzzles.
44

5-
### Requirements
5+
### 🎄 Advent of Code Quiz Information
6+
7+
<details>
8+
<summary><b style="font-size: 24px;">2024</b></summary>
9+
10+
- Day 1: Historian Hysteria [[link]](/src/2024/2024-12-01/README.md)
11+
12+
</details>
13+
14+
### Table of Contents
15+
16+
<details>
17+
<summary>Click to expand the table of contents</summary>
18+
19+
- [Advent of Code Quiz Information](#-advent-of-code-quiz-information)
20+
- [Project Folder Structure](#-project-folder-structure)
21+
- [Requirements](#-requirements)
22+
- [Installation](#%EF%B8%8F-installation)
23+
- [Usage](#-usage)
24+
- [Alternate Usage](#-alternate-usage)
25+
- [Available Scripts](#-available-scripts)
26+
27+
</details>
28+
29+
## 📚 Project Folder Structure
30+
31+
It follows the directory structure:
32+
33+
> [!NOTE]
34+
> 📂 dist<br>
35+
> 📂 src<br>
36+
> └─ 📂 lib<br>
37+
> └─ 📂 sample<br>
38+
> └─ 📂 2024<br>
39+
> └─── 📂 2024-12-01<br>
40+
> └───── 📂 lib<br>
41+
> └───── 📄 input.txt<br>
42+
> └───── 📄 quiz.ts<br>
43+
> └───── 📄 quiz.test.ts<br>
44+
> └───── 📄 sample.test.ts<br>
45+
> └───── 📄 README.md<br>
46+
> └─── 📂 2024-12-02<br>
47+
> └─── 📂 ...<br>
48+
> └─ 📂 2025<br>
49+
> └─ 📂 ...<br>
50+
> └─ 📄 index.ts<br>
51+
> └─ 📄 ...<br>
52+
> 📄 README.md
53+
54+
#### Quiz Folders
55+
56+
Each Advent of Code (AOC) event quiz has its folder under **`"/src/<YEAR>/<YYYY-MM-DD>"`** containing:
57+
- **/lib**: Folder containing main quiz solution logic
58+
- **input.txt**: Quiz input from AOC
59+
- **quiz.ts**: Quiz answer(s) validated with AOC
60+
- **quiz.test.ts**: Test of the correct quiz answers
61+
- **sample.test.ts**: Minimal sample input with expected correct answers
62+
- **README.md**: Static copy of the AOC quiz question
63+
64+
#### Other Items
65+
66+
- **/src/lib**: Folder containing generic utility helper functions
67+
- **/src/dist**: Folder containing the JavaScript files compiled from TypeScript (not committed to the repository)
68+
- **/src/sample**: Miscellaneous random examples
69+
- **/src/index.ts**: Exports all solutions to AOC quiz answer functions
70+
71+
### 📋 Requirements
672

773
- Node v20.15.0
874
- node: 20.15.0
975
- npm: 10.7.0
1076

11-
## Installation
77+
- Docker (optional)
78+
79+
## 🛠️ Installation
1280

1381
1. Clone the repository.
1482
```
@@ -20,12 +88,11 @@ Solutions for [Advent of Code](https://adventofcode.com/) event puzzles.
2088
npm install
2189
```
2290

23-
24-
## Usage
91+
## 🚀 Usage
2592

2693
Using Node
2794

28-
1. Run a TypeScript file inside the **/src** directory. For example:
95+
1. Run a non-test TypeScript file inside the **/src** directory. For example:
2996

3097
```
3198
npx vite-node src/sample/sample.ts
@@ -37,7 +104,7 @@ Using Node
37104
```
38105
3. See the [Available Scripts](#available-scripts) section for more information.
39106

40-
## Alternate Usage
107+
## Alternate Usage
41108

42109
Using Docker
43110

@@ -61,7 +128,10 @@ Using Docker
61128
docker run -it -v ${pwd}:/opt/app -v /opt/app/node_modules --rm weaponsforge/adventofcode:dev <AVAILABLE_SCRIPT>
62129
```
63130

64-
## Available Scripts
131+
## 📜 Available Scripts
132+
133+
<details>
134+
<summary>Click to expand the list of available scripts</summary>
65135

66136
### `npm run dev`
67137

@@ -95,5 +165,8 @@ Fixes TypeScript lint errors.
95165

96166
Runs tests defined in `*.test.ts` files.
97167

168+
</details>
169+
<br>
170+
98171
@weaponsforge<br>
99172
20241213

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adventofcode",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Solutions for Advent of Code https://adventofcode.com/ event puzzles",
55
"main": "dist/index.js",
66
"type": "module",

src/2024/2024-12-01/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
## Day 1: Historian Hysteria
2+
3+
**Source:** https://adventofcode.com/2024/day/1<br>
4+
**Status:** Complete
5+
6+
### 📘 Part 1
7+
8+
The Chief Historian is always present for the big Christmas sleigh launch, but nobody has seen him in months! Last anyone heard, he was visiting locations that are historically significant to the North Pole; a group of Senior Historians has asked you to accompany them as they check the places they think he was most likely to visit.
9+
10+
As each location is checked, they will mark it on their list with a star. They figure the Chief Historian must be in one of the first fifty places they'll look, so in order to save Christmas, you need to help them get fifty stars on their list before Santa takes off on December 25th.
11+
12+
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
13+
14+
You haven't even left yet and the group of Elvish Senior Historians has already hit a problem: their list of locations to check is currently empty. Eventually, someone decides that the best place to check first would be the Chief Historian's office.
15+
16+
Upon pouring into the office, everyone confirms that the Chief Historian is indeed nowhere to be found. Instead, the Elves discover an assortment of notes and lists of historically significant locations! This seems to be the planning the Chief Historian was doing before he left. Perhaps these notes can be used to determine which locations to search?
17+
18+
Throughout the Chief's office, the historically significant locations are listed not by name but by a unique number called the location ID. To make sure they don't miss anything, The Historians split into two groups, each searching the office and trying to create their own complete list of location IDs.
19+
20+
There's just one problem: by holding the two lists up side by side (your puzzle input), it quickly becomes clear that the lists aren't very similar. Maybe you can help The Historians reconcile their lists?
21+
22+
For example:
23+
24+
```text
25+
3 4
26+
4 3
27+
2 5
28+
1 3
29+
3 9
30+
3 3
31+
```
32+
33+
Maybe the lists are only off by a small amount! To find out, pair up the numbers and measure how far apart they are. Pair up the smallest number in the left list with the smallest number in the right list, then the second-smallest left number with the second-smallest right number, and so on.
34+
35+
Within each pair, figure out how far apart the two numbers are; you'll need to add up all of those distances. For example, if you pair up a 3 from the left list with a 7 from the right list, the distance apart is 4; if you pair up a 9 with a 3, the distance apart is 6.
36+
37+
In the example list above, the pairs and distances would be as follows:
38+
39+
- The smallest number in the left list is 1, and the smallest number in the right list is 3. The distance between them is 2.
40+
- The second-smallest number in the left list is 2, and the second-smallest number in the right list is another 3. The distance between them is 1.
41+
- The third-smallest number in both lists is 3, so the distance between them is 0.
42+
- The next numbers to pair up are 3 and 4, a distance of 1.
43+
- The fifth-smallest numbers in each list are 3 and 5, a distance of 2.
44+
- Finally, the largest number in the left list is 4, while the largest number in the right list is 9; these are a distance 5 apart.
45+
46+
To find the total distance between the left list and the right list, add up the distances between all of the pairs you found. In the example above, this is `2 + 1 + 0 + 1 + 2 + 5`, a total distance of `11`!
47+
48+
Your actual left and right lists contain many location IDs. What is the total distance between your lists?
49+
50+
> **Your puzzle answer was** 2086478.
51+
52+
---
53+
54+
### 📗 Part 2
55+
56+
Your analysis only confirmed what everyone feared: the two lists of location IDs are indeed very different.
57+
58+
Or are they?
59+
60+
The Historians can't agree on which group made the mistakes or how to read most of the Chief's handwriting, but in the commotion you notice an interesting detail: a lot of location IDs appear in both lists! Maybe the other numbers aren't location IDs at all but rather misinterpreted handwriting.
61+
62+
This time, you'll need to figure out exactly how often each number from the left list appears in the right list. Calculate a total similarity score by adding up each number in the left list after multiplying it by the number of times that number appears in the right list.
63+
64+
Here are the same example lists again:
65+
66+
```text
67+
3 4
68+
4 3
69+
2 5
70+
1 3
71+
3 9
72+
3 3
73+
```
74+
75+
For these example lists, here is the process of finding the similarity score:
76+
77+
- The first number in the left list is `3`. It appears in the right list three times, so the similarity score increases by `3 * 3 = 9`.
78+
- The second number in the left list is `4`. It appears in the right list once, so the similarity score increases by `4 * 1 = 4`.
79+
- The third number in the left list is `2`. It does not appear in the right list, so the similarity score does not increase `(2 * 0 = 0)`.
80+
- The fourth number, `1`, also does not appear in the right list.
81+
- The fifth number, `3`, appears in the right list three times; the similarity score increases by `9`.
82+
- The last number, `3`, appears in the right list three times; the similarity score again increases by `9`.
83+
84+
So, for these example lists, the similarity score at the end of this process is `31 (9 + 4 + 0 + 0 + 9 + 9)`.
85+
86+
Once again consider your left and right lists. What is their similarity score?
87+
88+
> **Your puzzle answer was** 24941624.

0 commit comments

Comments
 (0)