Skip to content

Commit f0e5756

Browse files
authored
Merge pull request #52 from weaponsforge/dev
v1.2.2
2 parents 4a01a3c + 0fff207 commit f0e5756

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+4513
-279
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ jobs:
2626
run: npm run lint
2727

2828
- name: Transpile
29-
run: npm run transpile
29+
run: npm run transpile:noemit
3030

3131
- name: Test
3232
run: npm test
33-

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
## ✨ adventofcode
22

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

5-
The codes are structured in a way that discusses and walks through the solution steps for the AoC quizzes rather than focusing on AoC's competitive programming.
5+
- The code repository structure follows a way that discusses and walks through the solution steps for the AoC quizzes rather than focusing on AoC's competitive programming.
6+
- The quizzes were solved for fun (unlocking the 2024 AoC Chrismas symbol 🎄) and brain exercise purposes. Therefore, no GPT or AI completion was used for solving, as advised on the AoC website.
7+
- These codes may get occasional optimization updates or solutions using other languages from time to time.
68

79
### 🎄 Advent of Code Quiz Information
810

@@ -19,6 +21,11 @@ The codes are structured in a way that discusses and walks through the solution
1921
- Day 8: Resonant Collinearity [[link]](/src/2024/2024-12-08/README.md)
2022
- Day 9: Disk Fragmenter [[link]](/src/2024/2024-12-09/README.md)
2123
- Day 10: Hoof It [[link]](/src/2024/2024-12-10/README.md)
24+
- Day 11: Plutonian Pebbles [[link]](/src/2024/2024-12-11/README.md)
25+
- Day 12: Garden Groups [[link]](/src/2024/2024-12-12/README.md)
26+
- Day 13: Claw Contraption [[link]](/src/2024/2024-12-13/README.md)
27+
- Day 14: Restroom Redoubt [[link]](/src/2024/2024-12-14/README.md)
28+
- Day 15: Warehouse Woes [[link]](/src/2024/2024-12-15/README.md)
2229

2330
</details>
2431

@@ -44,7 +51,7 @@ It follows the directory structure:
4451
> [!NOTE]
4552
> 📂 dist<br>
4653
> 📂 src<br>
47-
> └─ 📂 utils<br>
54+
> └─ 📂 aoc<br>
4855
> └─ 📂 sample<br>
4956
> └─ 📂 2024<br>
5057
> └─── 📂 2024-12-01<br>
@@ -63,19 +70,20 @@ It follows the directory structure:
6370
6471
#### Quiz Folders
6572

66-
Each Advent of Code (AOC) event quiz has its folder under **`"/src/<YEAR>/<YYYY-MM-DD>"`** containing:
73+
Each Advent of Code (AoC) event quiz has its folder under **`"/src/<YEAR>/<YYYY-MM-DD>"`** containing:
6774
- **/lib**: Folder containing main quiz solution logic
6875
- **input.txt**: Random quiz input
76+
> _**INFO:** The sample quiz inputs were slightly altered from the original AoC input text and quiz samples as advised on their website_
6977
- **main.ts**: Main program entry point containing quiz answer(s) using random input
7078
- **sample.test.ts**: Minimal sample input with expected correct answers
71-
- **README.md**: Reference and other notes about the AOC quiz question
79+
- **README.md**: Reference and other notes about the AoC quiz question
7280

7381
#### Other Items
7482

75-
- **/src/utils**: Folder containing generic utility helper functions
83+
- **/src/aoc**: 🗃️ Folder containing generic utility and common AoC helper functions
7684
- **/src/dist**: Folder containing the JavaScript files compiled from TypeScript (not committed to the repository)
7785
- **/src/sample**: Miscellaneous random examples
78-
- **/src/index.ts**: Exports all solutions to AOC quiz answer functions
86+
- **/src/index.ts**: Exports all solutions to AoC quiz answer functions
7987

8088
### 📋 Requirements
8189

@@ -101,7 +109,7 @@ Each Advent of Code (AOC) event quiz has its folder under **`"/src/<YEAR>/<YYYY-
101109

102110
Using Node
103111

104-
1. (Optional) Replace the values of specific `input.txt` in the `"/src/<YEAR>/<YYYY-MM-DD>"` directories with actual AOC input.
112+
1. (Optional) Replace the values of specific `input.txt` in the `"/src/<YEAR>/<YYYY-MM-DD>"` directories with actual AoC input.
105113
2. Run a non-test TypeScript file inside the **/src** directory from the project's _**"root directory"**_. For example:
106114
```
107115
npx vite-node src/sample/sample.ts
@@ -166,6 +174,10 @@ Runs the sample TS script.
166174

167175
Builds the JavaScript files from the TypeScript files.
168176

177+
### `npm run transpile:noemit`
178+
179+
Runs type-checking without generating the JavaScript or declatation files from the TypeScript files.
180+
169181
### `npm run lint`
170182

171183
Lints TypeScript source codes.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dev": "vitest",
1313
"dev:debug": "vite-node src/sample/sample.ts",
1414
"transpile": "tsc -p tsconfig.json && tsc-alias",
15+
"transpile:noemit": "tsc -p tsconfig.json --noEmit",
1516
"watch": "tsc -p tsconfig.json --watch",
1617
"watch:docker:win": "tsc -p tsconfig.json --watch --watchFile dynamicPriorityPolling --watchDirectory dynamicPriorityPolling",
1718
"lint": "eslint \"src/**/*.ts\" *.mjs *.ts",

src/2024/2024-12-01/lib/fileReader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path'
2-
import { readFile, directory } from '@/utils/file.js'
2+
import { readFile, directory } from '@/aoc/file/utils.js'
33

44
export type arrayLists = {
55
list1: string[];

src/2024/2024-12-01/lib/listTotalDistance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { arrangeArray, ARRAY_ORDERING } from '@/utils/arrays.js'
1+
import { arrangeArray, ARRAY_ORDERING } from '@/aoc/array/utils.js'
22

33
/**
44
* Calculates the total distance between the smallest value-pairs from list `a` and list `b`

src/2024/2024-12-02/lib/fileReader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path'
2-
import { readFile, directory } from '@/utils/file.js'
2+
import { readFile, directory } from '@/aoc/file/utils.js'
33

44
/**
55
* Reads the quiz's input file into two (2) string arrays

src/2024/2024-12-03/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path'
2-
import { directory, readFile } from '@/utils/file.js'
2+
import { directory, readFile } from '@/aoc/file/utils.js'
33
import { extractMultiply, extractMultiplyCondition } from './lib/extractMultiply.js'
44

55
const dir = directory(import.meta.url)

src/2024/2024-12-04/lib/wordCheckerUtils.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
export type CharacterArray = string[][]
2-
3-
interface CoordinateBase {
4-
x: number;
5-
y: number;
6-
}
7-
8-
interface Coordinate extends CoordinateBase {
9-
direction: 1 | -1;
10-
}
11-
12-
interface CoordinateData {
13-
xDirection: 1 | -1;
14-
yDirection: 1 | -1;
15-
data: CharacterArray
16-
}
1+
import type {
2+
Coordinate,
3+
Point,
4+
CoordinateData
5+
} from '@/aoc/point/types.js'
176

187
/**
198
* Finds the `WORD` input parameter in the vertical directions (up/down) from an (x,y) coordinate
@@ -23,11 +12,11 @@ interface CoordinateData {
2312
* @param coord.direction {number} Up or down letter-checking direction
2413
* - `-1` for "up" going to (0,0)
2514
* - `1` for "down" going to (N,N) from the `coord`
26-
* @param fullData {CharacterArray} 2D array of strings consisting of letters per item
15+
* @param fullData {string[][]} 2D array of strings consisting of letters per item
2716
* @param WORD {string} Word to find
2817
* @returns {boolean} Flag indicating the existence of the `WORD`
2918
*/
30-
export const checkVertical = (coord: Coordinate, fullData: CharacterArray, WORD: string): boolean => {
19+
export const checkVertical = (coord: Coordinate, fullData: string[][], WORD: string): boolean => {
3120
let yIndex = coord.y
3221
let subWord = ''
3322

@@ -79,11 +68,11 @@ export const checkHorizontal = (coord: Coordinate, rowData: string[], WORD: stri
7968
* @typedef param {CoordinateData} Direction and data object
8069
* @param param.xDirection {number} `-1` for "left" going to (0,0) or `1` for "right" going to (N,N) from the `coord`
8170
* @param param.yDirection {number} `-1` for "up" going to (0,0) or `1` for "down" going to (N,N) from the `coord`
82-
* @param param.data {CharacterArray} 2D string array containing the input text
71+
* @param param.data {string[][]} 2D string array containing the input text
8372
* @returns {boolean} Flag indicating the existence of the `WORD`
8473
* @param WORD {string} Word to find
8574
*/
86-
export const checkDiagonal = (coord: CoordinateBase, param: CoordinateData, WORD: string): boolean => {
75+
export const checkDiagonal = (coord: Point, param: CoordinateData, WORD: string): boolean => {
8776
let xIndex = coord.x
8877
let yIndex = coord.y
8978
let subWord = ''

src/2024/2024-12-04/lib/wordCount.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { checkVertical, checkHorizontal, checkDiagonal } from './wordCheckerUtil
22

33
/**
44
* Counts the number of occurence of the `WORD` from a set of input
5-
* @param data {CharacterArray} 2D string array containing the input text
5+
* @param data {string[][]} 2D string array containing the input text
66
* @param WORD_TO_FIND {string} Word to find
77
* @returns {number} Number of `WORD`s
88
*/

src/2024/2024-12-04/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path'
2-
import { directory, readFile } from '@/utils/file.js'
2+
import { directory, readFile } from '@/aoc/file/utils.js'
33
import { wordCount } from './lib/wordCount.js'
44
import { countMASword } from './lib/xmasCount.js'
55

0 commit comments

Comments
 (0)